-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusing-sqlite.py
More file actions
30 lines (20 loc) · 683 Bytes
/
Copy pathusing-sqlite.py
File metadata and controls
30 lines (20 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sqlite3
conn = sqlite3.connect('database.db')
print("Opened database successfully")
conn.execute('''CREATE TABLE DATA
(ID INT PRIMARY KEY NOT NULL,
CONTENT TEXT NOT NULL);''')
print("Table created successfully")
#Hello world in English
conn.execute("INSERT INTO DATA(ID,CONTENT) \
VALUES (1, 'Hello World')")
#Hello world in Portuguese
conn.execute("INSERT INTO DATA(ID,CONTENT) \
VALUES (2, 'Ola Mundo')")
conn.commit()
print("Records created successfully")
print("=================================")
cursor = conn.execute("SELECT id, content from DATA ")
for row in cursor:
print("content:", row[1])
conn.close()