Simplest sqlite3 Python Tutorial
1. create a database
```#https://docs.python.org/3/library/sqlite3.html
#https://pynative.com/python-sqlite-blob-insert-and-retrieve-digital-data/
import sqlite3
conn = sqlite3.connect('example.db')
c = conn.cursor()
```
2. create a table
```c.execute('''CREATE TABLE IF NOT EXISTS thoughts
(date TEXT, data BLOB)''')
```
3. write your data
```# Insert a row of data
c.execute("INSERT INTO thoughts VALUES (?,?)", ('2006-01-05',b'y ingshaoxo said'))
# Larger example that inserts many records at a time
purchases = [
('2006-03-28', b'hi'),
('2006-04-05', b"everyone"),
]
c.executemany('INSERT INTO thoughts VALUES (?,?)', purchases)
# Save the changes
conn.commit()
```
4. select many
```for row in c.execute('SELECT * FROM thoughts ORDER BY date'):
print(row)
```
5. select one
```target = ('2006-03-28',)
c.execute('SELECT * FROM thoughts WHERE date=?', target)
print(c.fetchone())
```
6. close the connection
```# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
```