#import the sqlite3 module
import sqlite3
#create a tble
with sqlite3.connect(':memory:') as conn:
#create a table
conn.execute('''
CREATE TABLE point(
id INTEGER PRIMARY KEY AUTOINCREMENT,
x INTEGER,
y INTEGER
)
''')
#populate table
conn.executescript('''
INSERT INTO point (x, y) VALUES (3, 4);
INSERT INTO point (x, y) VALUES (2, 3);
INSERT INTO point (x, y) VALUES (-2, 5);
''')
#retrieve data
cursor = conn.cursor()
cursor.execute('SELECT x, y FROM point;')
print(cursor.fetchall())
cursor.close()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter