最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
python3 sqlite3限制条件查询操作代码
时间:2022-06-25 02:08:10 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下python3 sqlite3限制条件查询操作代码,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
请注意10,11,24行的代码,代码如下:
import json import sqlite3 import re import argparse def Get(db_file): conn = sqlite3.connect(db_file) cur = conn.cursor() print("5555555") value1=(60)# this is must be () cur.execute("select * from exception where AGV_ID=(%s)" %(value1)) #cursor.execute("insert into exception values('%s', '%s','%s' ) " %(start_time ,ID ,infomation)) result= cur.fetchall() print("result:",result) for i in result: print(i) print("******************************888") def get_agv_id(db_file): try: conn = sqlite3.connect(db_file) cur = conn.cursor() cur.execute("select * from exception where AGV_ID=51") #print( cur.fetchall()) result= cur.fetchall() for i in result: print(i) except sqlite3.Error,e: print(e) if __name__ == '__main__': parser = argparse.ArgumentParser(description='check the information of db') #parser.add_argument('-h', '--help', help='Statistics for abnormal information') parser.add_argument('-n', '--name', help=' the db of name ') args = vars(parser.parse_args()) db_name = args['name'] print("db_name:",db_name) conn = sqlite3.connect('db_name') cursor = conn.cursor() Get('fitkits.db') get_agv_id('fitkits.db') conn.commit() conn.close() print('DONE!') print("666")
相关文章
- 碧蓝航线的里雅斯特期待的便当时间皮肤有什么 04-30
- 明日之后踏浪逐星服装展示攻略 04-30
- 深空之眼幽月塞勒涅刻印搭配核心思路 04-30
- 明日之后红杉茶会护卫队首领BOSS有哪些 04-30
- CF手游段位奖励汇总攻略 04-30
- 无期迷途5-13怎么走攻略 04-30