-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
20 lines (17 loc) · 733 Bytes
/
database.py
File metadata and controls
20 lines (17 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""
Database saving simulation results for future analysis.
"""
from contextlib import closing
import sqlite3
def export(probabilities, search_distances, base_lengths):
"""
Save the probabilities, search distances, and base lengths to a
three-column sqlite3 database.
"""
with closing(sqlite3.connect("results.db")) as connection:
with closing(connection.cursor()) as cursor:
cursor.execute("DROP TABLE results")
cursor.execute("CREATE TABLE results(probability, distance, base)")
cursor.executemany("INSERT INTO results VALUES(?, ?, ?)",
zip(probabilities, search_distances, base_lengths))
connection.commit()