当前位置:首页 > 数据库 > SQlite

python使用sqlite示例

sqlite3 conn = sqlite3.connect(‘test.db‘) cursor = conn.cursor() cursor.execute(‘select * from user‘) values = cursor.fetchall() for value in values: print(value) cursor.close() conn.close()
  • 执行INSERT等操作后要调用commit()提交事务;

  • MySQL的SQL占位符是%s,sqlite的占位符是?

示例:

cursor.execute(‘select * from user where id = %s‘, (‘1‘,))  // mysql的插入语句
cursor.execute(‘select * from user where id=?‘, (‘1‘,))     // sqlite的插入语句

 

python使用sqlite示例

标签:blog   一个数据库   获得   连接   for   imp   .exe   事务   一个   

本文系统来源:https://www.cnblogs.com/ncuhwxiong/p/8157253.html


【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!