Esempio n. 1
0
 def setUpClass(cls):
     Post.create_table()
Esempio n. 2
0
from models.user import User
from models.post import Post

def make_dicts(cursor, row):
    return dict((cursor.description[idx][0], value)
                for idx, value in enumerate(row))

  
db = sqlite3.connect('.data/db.sqlite')
db.row_factory = make_dicts

cur = db.cursor()

User.create_table(cur)
Post.create_table(cur)


users = [
    User("Ford", "*****@*****.**", "12345"),
    User("Arthur", "*****@*****.**", "12345"),
]

posts = [
    Post(content="Hi!", author_id="*****@*****.**"),
    Post(content="Don't destroy the earth please!", author_id="*****@*****.**"),
]

for user in users:
    user.insert(cur)