In Python3.4, is it possible to open an SQLite3 database from an io.BytesIO stream?
Something akin to:
with open("temp.db", "rb") as openf:
byte_stream = io.BytesIO(openf.read())
sqlite3.connect(byte_stream)
The short story is: I have a stream (byte_stream) that is the sqlite database file. I can't do the following for security reasons (can't create an unencrypted file):
with open("temp.db", "wb") as openf:
openf.write(byte_stream)
sqlite3.connect("temp.db")
Is there some lower-level API for sqlite3 that I haven't been able to find? I assume that sqlite3.connect simply calls open() at some point and opens the file as a byte stream anyway. I'm simply trying to skip that open() step.
sqlite3_open_v2function, which takes a file name (or a VFS URL, but that's pretty advanced and IDK if Python exposes that API).open()is actually called - seeModules/_sqlite/connection.c:102for actual implementation (in C).