1.連結 關閉
import sqlite3
test=sqlite3.connect("mydb.db")
print("link database")
test.close()
print("database close")
2.建立資料表
import sqlite3
test=sqlite3.connect("mydb.db")
try:
creTabList="CREATE TABLE 產品(編號 text,品名 text,單價 int)" #要輸入mydb.db 的欄位
test.execute(creTabList) #執行
test.commit() #更新資料庫
print("database table create ")
except Exception:
print("it don's work")
test.close()
沒有留言:
張貼留言