Skip to content

Commit ab9c5a0

Browse files
rhermanklinkdpgeorge
authored andcommitted
unix-ffi/sqlite3: Add optional parameter for URI support.
This commit adds the ability to enable URI on the connect, as can be done in the cpython sqlite3 module. URI allows, among other things, to create a shared named in-memory database, which non URI filenames cannot create. Signed-off-by: Robert Klink <rhermanklink@ripe.net>
1 parent 0a65c3d commit ab9c5a0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

unix-ffi/sqlite3/sqlite3.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
sq3 = ffilib.open("libsqlite3")
77

88
sqlite3_open = sq3.func("i", "sqlite3_open", "sp")
9+
# int sqlite3_config(int, ...);
10+
sqlite3_config = sq3.func("i", "sqlite3_config", "ii")
911
# int sqlite3_close(sqlite3*);
1012
sqlite3_close = sq3.func("i", "sqlite3_close", "p")
1113
# int sqlite3_prepare(
@@ -52,6 +54,8 @@
5254
SQLITE_BLOB = 4
5355
SQLITE_NULL = 5
5456

57+
SQLITE_CONFIG_URI = 17
58+
5559

5660
class Error(Exception):
5761
pass
@@ -136,7 +140,9 @@ def fetchone(self):
136140
check_error(self.h, res)
137141

138142

139-
def connect(fname):
143+
def connect(fname, uri=False):
144+
sqlite3_config(SQLITE_CONFIG_URI, int(uri))
145+
140146
sqlite_ptr = bytes(get_ptr_size())
141147
sqlite3_open(fname, sqlite_ptr)
142148
return Connections(int.from_bytes(sqlite_ptr, sys.byteorder))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy