diff --git a/sqlite3_test.py b/sqlite3_test.py new file mode 100755 index 0000000..e17073f --- /dev/null +++ b/sqlite3_test.py @@ -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()