python sqlite 时间查询

conn = get_conn(sqlite_path+os.sep+dbfile)
table_sql = "select name from sqlite_master where type='table' order by name"
cu = get_cursor(conn)
cu.execute(table_sql)
tablenames = cu.fetchall()
# print('tablenames:',tablenames) # [('sh600152',), ('sh600228',),..]


for symbol_table in tablenames:
    fetchall_sql = '''SELECT * FROM ''' + symbol_table[0] + """ where((strftime("%H",time)='09')and(strftime("%M",time)>='30')and(strftime("%M",time)<'31'))"""
    print(fetchall_sql)
    cu.execute(fetchall_sql)
    data = cu.fetchall()
    print (data)

你可能感兴趣的:(python sqlite 时间查询)