summaryrefslogtreecommitdiff
path: root/doc/includes/sqlite3/apsw_example.py
diff options
context:
space:
mode:
Diffstat (limited to 'doc/includes/sqlite3/apsw_example.py')
-rw-r--r--doc/includes/sqlite3/apsw_example.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/includes/sqlite3/apsw_example.py b/doc/includes/sqlite3/apsw_example.py
new file mode 100644
index 0000000..bdca0c9
--- /dev/null
+++ b/doc/includes/sqlite3/apsw_example.py
@@ -0,0 +1,12 @@
+from pysqlite2 import dbapi2 as sqlite3
+import apsw
+
+apsw_con = apsw.Connection(":memory:")
+apsw_con.createscalarfunction("times_two", lambda x: 2*x, 1)
+
+# Create pysqlite connection from APSW connection
+con = sqlite3.connect(apsw_con)
+result = con.execute("select times_two(15)").fetchone()[0]
+assert result == 30
+con.close()
+