Create a history database with the standard schema and some entries.
(hist_file: Path, n_entries: int)
| 480 | |
| 481 | |
| 482 | def _make_history_db(hist_file: Path, n_entries: int) -> None: |
| 483 | """Create a history database with the standard schema and some entries.""" |
| 484 | with closing(sqlite3.connect(hist_file)) as con: |
| 485 | con.execute( |
| 486 | """CREATE TABLE sessions (session integer |
| 487 | primary key autoincrement, start timestamp, |
| 488 | end timestamp, num_cmds integer, remark text)""" |
| 489 | ) |
| 490 | con.execute( |
| 491 | """CREATE TABLE history |
| 492 | (session integer, line integer, source text, source_raw text, |
| 493 | PRIMARY KEY (session, line))""" |
| 494 | ) |
| 495 | con.execute( |
| 496 | """CREATE TABLE output_history |
| 497 | (session integer, line integer, output text, |
| 498 | PRIMARY KEY (session, line))""" |
| 499 | ) |
| 500 | now = datetime.now().isoformat(sep=" ") |
| 501 | con.execute( |
| 502 | "INSERT INTO sessions VALUES (1, ?, ?, ?, '')", (now, now, n_entries) |
| 503 | ) |
| 504 | con.executemany( |
| 505 | "INSERT INTO history VALUES (1, ?, ?, ?)", |
| 506 | [(i, "code %d" % i, "code %d" % i) for i in range(n_entries)], |
| 507 | ) |
| 508 | con.commit() |
| 509 | |
| 510 | |
| 511 | @pytest.mark.parametrize( |
no test coverage detected
searching dependent graphs…