· 4 years ago · Aug 25, 2021, 09:50 AM
1import random, sqlite3
2
3conn = sqlite3.connect("people.db")
4cursor = conn.cursor()
5
6sql = 'create table if not exists people (age integer, name VARCHAR(255))'
7cursor.execute(sql)
8
9for x in range(5):
10 cursor.execute('insert into people VALUES (?, "junior")', (random.randint(1, 10000),))
11conn.commit()
12
13cursor.execute("select * from people")
14print("In database:", cursor.fetchall())