import sqlite3
def GetTables(db_file = 'test2.db'):
try:
conn = sqlite3.connect(db_file)
cur = conn.cursor()
cur.execute("select name from sqlite_master where type='table' order by name")
print( cur.fetchall())
except sqlite3.Error, e:
print e
# test.db is a file in the working directory
conn = sqlite3.connect("test2.db")
c = conn.cursor()
c.execute(''' create table name(
time text,
AGV_ID int,
infomation text);''')
# create tables
sql = '''create table student (id int primary key, name varchar(20), score int, sex varchar(10), age int)'''
c.execute(sql)
# save the changes
conn.commit()
GetTables(db_file = 'test1.db')
# close the connection with the database
conn.close()
python sqlite3 查看所有的数据表
最新推荐文章于 2025-04-20 22:27:39 发布