Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/python/python-wasm/src/extension/sqlite.test.ts
1067 views
1
import { syncPython } from "../node";
2
3
// TODO: note that non-in-memory sqlite currently definitely doesn't work at all... YET.
4
// That's clear even with the standalone binary.
5
6
test("use the sqlite module to do something", async () => {
7
const { exec, repr } = await syncPython();
8
exec(`
9
import sqlite3
10
con = sqlite3.connect(":memory:")
11
cur = con.cursor()
12
cur.execute("CREATE TABLE movies(title, year, score)")
13
cur.execute("INSERT INTO movies values('Red Dawn',1984,50)")
14
cur.execute("INSERT INTO movies values('Red Dawn',2012,15)")
15
res = cur.execute("SELECT * FROM movies")
16
`);
17
expect(repr("list(res)")).toBe(
18
"[('Red Dawn', 1984, 50), ('Red Dawn', 2012, 15)]"
19
);
20
});
21
22