feat: add sqlite_test.py
This commit is contained in:
25
sqlite3_test.py
Executable file
25
sqlite3_test.py
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/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()
|
||||
Reference in New Issue
Block a user