python sqlite

 

 

import sqlite3

# 连接到数据库
conn = sqlite3.connect('example.db')

# 创建一个Cursor对象
cursor = conn.cursor()

# 执行查询语句
cursor.execute('SELECT * FROM some_table')

# 获取查询结果
results = cursor.fetchall()

# 关闭Cursor和连接
cursor.close()
conn.close()

# 输出结果
for row in results:
    print(row)

 

 

###################

posted @ 2024-06-27 23:50  西北逍遥  阅读(3)  评论(0编辑  收藏  举报