Форум сайта python.su
Имеется функция которая выводит данные таблицы по выборке:
def zaprosbd (data, t1, t2): conn = sqlite3.connect('log.bd') curbd = conn.cursor() zapros1 = '''select * from temperatura where date = (?) and time between (?) and (?) order by date, time, temp''' curbd.execute (zapros1, (data, t1, t2)) for row in curbd: sp = (row) print (sp) conn.commit() curbd.close return sp
data = "2015-09-30" t1 = "12:19:40" t2 = "15:28:09" x = zaprosbd (data, t1, t2) print (x)
Офлайн
def zaprosbd (data, t1, t2): conn = sqlite3.connect('log.bd') curbd = conn.cursor() zapros1 = '''select * from temperatura where date = (?) and time between (?) and (?) order by date, time, temp''' curbd.execute(zapros1, (data, t1, t2)) curbd.close() conn.close() return curbd.fetchall()
date = "2015-09-30" t1 = "12:19:40" t2 = "15:28:09" x = zaprosbd (date, t1, t2) for item in x: print(item)
Офлайн
Спасибо! Работает как нужно.
Офлайн