26 lines
612 B
Python
Executable File
26 lines
612 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import sqlite3
|
|
|
|
if __name__ == "__main__":
|
|
conn = sqlite3.connect("test.db")
|
|
cursor = conn.cursor()
|
|
cursor.execute('''
|
|
CREATE TABLE IF NOT EXISTS test (id text, name text)
|
|
''')
|
|
cursor.execute("INSERT INTO test (id, name) values ('key', 'value')")
|
|
cursor.executemany(
|
|
"INSERT INTO test (id, name) values (?, ?)", [
|
|
('key-2', 'value-2'),
|
|
('key-3', 'value-3'),
|
|
]
|
|
)
|
|
conn.commit()
|
|
|
|
cursor.execute("SELECT * FROM test")
|
|
for row in cursor.fetchall():
|
|
print(row)
|
|
|
|
cursor.close()
|
|
conn.close()
|