· 6 years ago · Apr 01, 2019, 11:04 PM
1import sqlite3
2
3with sqlite3.connect('blog.db') as conn:
4
5 conn.execute(
6 "CREATE TABLE IF NOT EXISTS posts"
7 "(title TEXT, post TEXT)"
8 )
9
10
11 # insert dummy data into the table
12 # number_of_posts = conn.execute("SELECT count(posts)")
13
14 conn.execute('INSERT INTO posts VALUES("Good", "I\'m good.")')
15 conn.execute('INSERT INTO posts VALUES("Well", "I\'m well.")')
16 conn.execute('INSERT INTO posts VALUES("Excellent", "I\'m excellent.")')
17 conn.execute('INSERT INTO posts VALUES("Okay", "I\'m okay.")')