From bb9cc1216873604459724860d606283c398ea06b Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Thu, 2 Feb 2017 20:25:20 +0100 Subject: [feat] add support for the blob interface Pysqlcipher support for the sqlite blob interface: https://sqlite.org/c3ref/blob_open.html Copying the code from the PR in pysqlite: https://github.com/ghaering/pysqlite/pull/93 --- doc/examples/blob.py | 13 +++++++++++++ doc/examples/blob_with.py | 12 ++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 doc/examples/blob.py create mode 100644 doc/examples/blob_with.py (limited to 'doc/examples') diff --git a/doc/examples/blob.py b/doc/examples/blob.py new file mode 100644 index 0000000..2d63b9c --- /dev/null +++ b/doc/examples/blob.py @@ -0,0 +1,13 @@ +from pysqlcipher import dbapi2 as sqlite3 +con = sqlite3.connect(":memory:") +# creating the table +con.execute("create table test(id integer primary key, blob_col blob)") +con.execute("insert into test(blob_col) values (zeroblob(10))") +# opening blob handle +blob = con.blob("test", "blob_col", 1, 1) +blob.write("a" * 5) +blob.write("b" * 5) +blob.seek(0) +print blob.read() # will print "aaaaabbbbb" +blob.close() + diff --git a/doc/examples/blob_with.py b/doc/examples/blob_with.py new file mode 100644 index 0000000..fff9037 --- /dev/null +++ b/doc/examples/blob_with.py @@ -0,0 +1,12 @@ +from pysqlcipher import dbapi2 as sqlite3 +con = sqlite3.connect(":memory:") +# creating the table +con.execute("create table test(id integer primary key, blob_col blob)") +con.execute("insert into test(blob_col) values (zeroblob(10))") +# opening blob handle +with con.blob("test", "blob_col", 1, 1) as blob: + blob.write("a" * 5) + blob.write("b" * 5) + blob.seek(0) + print blob.read() # will print "aaaaabbbbb" + -- cgit v1.2.3