python-by-example-150-chall.../challenges139-145/challenge-139.py

13 lines
586 B
Python
Raw Normal View History

2019-08-05 21:33:21 +08:00
import sqlite3
with sqlite3.connect('python-by-example') as db:
cursor = db.cursor()
cursor.execute("""CREATE TABLE IF NOT EXISTS employees(
id integer PRIMARY KEY,
name text NOT NULL,
dept text NOT NULL,
salary integer);""")
cursor.execute("""INSERT INTO employees(id,name,dept,salary)
VALUES("1","Bob","Sales","25000")""")
db.commit()