# -*- coding: utf-8 -*- import sqlite3 conn = sqlite3.connect('testdemo.db') # 创建一个Cursor: cursor = conn.cursor() # 执行一条SQL语句,创建user表: cursor.execute('create table user (id varchar(20) primary key, name varchar(20))') # 继续执行一条SQL语句,插入一条记录: cursor.execute('insert into user (id, name) values (\'1\', \'Michael\')') cursor.execute('select * from user where id=?', ('1',)) value=cursor.fetchall() print (value) cursor.rowcount # 关闭Cursor: cursor.close() # 提交事务: conn.commit() # 关闭Connection: conn.close()
sqlite(python)
最新推荐文章于 2024-04-12 20:00:00 发布