def runupdatedb(): db = dbconnect.dbworker() dbversion = getdbversion() #q = "" for i in range(dbversion, len(sqltables.updatequeryes)): for q in sqltables.updatequeryes[i]: db.cursor.execute(q) db.db.commit() return "complate!!!"
def getdbversion(): db = dbconnect.dbworker() sql = "show tables from c9 like 'sysinfo'" db.cursor.execute(sql) userrow = db.cursor.fetchone() if userrow is None: ver = 0 else: sql = "select value from sysinfo where key_name = 'versiondb'" db.cursor.execute(sql) userrow = db.cursor.fetchone() if userrow is None: ver = 0 else: ver = int(userrow[0]) return ver
def index(request): #loadmysqlcredential() authorities = ez.checkauthorize(request) context = {"authorities": authorities, "location": "myadmin"} if (authorities.have): d = dbconnect.dbworker() d.doinitdb() t = hg.htmlgn(request) t.setjsrootname(request.path) t.append(hg.htmltext("Initialization complete!!!")) httptext = t.gen() return HttpResponse(httptext) else: return render(request, 'necessaryauth.html', context)
def __init__(self): self.db = dbconnect.dbworker() self.sql = u"""INSERT INTO goods (id, shop, caption, unit) VALUES ('{0}', '{1}', '{2}', '{3}')