Python_查看sqlite3表结构,查询语句的示例代码

Carol ·
更新时间:2024-09-20
· 508 次阅读

如下所示:

#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sqlite3 conn = sqlite3.connect('test.db') # 创建一个Cursor: cursor = conn.cursor() # 查询记录: conn = sqlite3.connect('calendar.db') cursor = conn.cursor() # 执行查询语句: cursor.execute('select * from perpetualCalendar') # 获得查询结果集: values = cursor.fetchall() print(values) # cursor.execute('PRAGMA table_info(perpetualCalendar)') print (cursor.fetchall()) cursor.close() conn.close()

查看表结构:cursor.execute('PRAGMA table_info(表名)')

以上这篇Python_查看sqlite3表结构,查询语句的示例代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持软件开发网。

您可能感兴趣的文章:python使用if语句实现一个猜拳游戏详解python标记语句块使用方法总结python语言基本语句用法总结如何在Python中实现goto语句的方法python 正则表达式获取字符串中所有的日期和时间使用Python将字符串转换为格式化的日期时间字符串Python如何计算语句执行时间



示例 sqlite3 SQLite Python

需要 登录 后方可回复, 如果你还没有账号请 注册新账号