Connect
import sqlite3 con = sqlite3.connect('db.sqlite3') con.close() # equivlent to with sqlite3.connect('db.sqlite3') as con:
Cursor
import sqlite3 con = sqlite3.connect('db.sqlite3') cur = con.cursor() cur.execute(``` CREATE TABLE messages ( ) ```) con.commit() con.close() # equivlent to with sqlite3.connect('db.sqlite3') as con: cur = con.cursor() cur.execute(``` CREATE TABLE messages ( ) ```) con.commit()
References
- Python3.5技術手冊 林信良 碁峰