Reputation: 339
I have a bytestring that holds the contents of a valid sqlite3 database. I have to save this bytestring to a file and call:
conn=sqlite3.connect("FILE_NAME")
I would rather not have to save this string to a file because I already have it in memory. Is there any way to create the connection object without this intermediate step?
Thanks.
This is Python 3.
Upvotes: 2
Views: 505
Reputation: 149175
AFAIK you cannot. There are various ways to use a in memory database, either with a memory file system, or with the special database ':memory:'
. But in either case, the database is an opaque object that is known only by its Connection object, and you can neither (easily) load or store it.
The best I can imagine with a memory file system is to use it to write the byte string in a memory file, and let sqlite use it. That way nothing has been writen on disk, but you have not really accessed directly the byte string....
Upvotes: 2