def exec_selsql(conftarget, strsql, colidx=-1): data = db(conftarget).exec_selsql(strsql) if colidx < 0: return data arr = [] for r in data: arr.append(r[colidx]) return arr
def g_get_data(conftarget, strsql): cursor = db(conftarget).get_cursor() cursor.execute(strsql) for row in cursor: tpl = () for col in row: tpl += (col,) yield tpl cursor.close()
def g_get_kabuka(meigaras=[], startd="", endd=""): strsql = "select code, date, open, high, low, close, volume from trade.kabuka" wherestr = general_kabuka_where(meigaras, startd, endd) strsql = strsql + wherestr strsql = strsql + " order by code, date ;" cursor = db().get_cursor() cursor.execute(strsql) for row in cursor: i = iter(row) code = next(i) date = next(i) open = next(i) high = next(i) low = next(i) close = next(i) vol = next(i) yield (code, date, open, high, low, close, vol) cursor.close()
def exec_updsql(conftarget, strsql): db(conftarget).exec_updsql(strsql)
def exec_selsqlh(conftarget, strsql): return db(conftarget).exec_selsqlh(strsql)
def exec_updsql(strsql): db().exec_updsql(strsql)
def exec_selsqlh(strsql): return db().exec_selsqlh(strsql)