MCPcopy Index your code
hub / github.com/ipython/ipython / _make_history_db

Function _make_history_db

tests/test_history.py:482–508  ·  view source on GitHub ↗

Create a history database with the standard schema and some entries.

(hist_file: Path, n_entries: int)

Source from the content-addressed store, hash-verified

480
481
482def _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(

Callers 1

test_history_trim_cliFunction · 0.85

Calls 3

connectMethod · 0.80
executeMethod · 0.80
commitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…