Re: [sqlite] "Pickling" an in-memory SQLite database.

2019-01-31 Thread Thomas Levine
If sqlite3_serialize and sqlite3_deserialize are not exposed in your bindings, 
I suppose you can do something like

with NamedTemporaryFile(mode='rb', prefix=prefix) as tmp:
c = sqlite3.connect(tmp.name)
# Do stuff.
c.close()
serialized = tmp.file.read()

where "prefix" is a RAM filesystem.

sqlite3_serialize and sqlite3_deserialize are better though.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] "Pickling" an in-memory SQLite database.

2019-01-31 Thread Shawn Wagner
sqlite3_serialize() and deserialize would work:
https://www.sqlite.org/c3ref/serialize.html

On Thu, Jan 31, 2019, 4:47 PM Randall Smith  Hi, guys.
>
> I have an application that allows me to embed a (potentially large) block
> of data into its application file at close, and read the block back on
> open.  It would be convenient and attractive for me, for a plugin I am
> writing for this application, to be able to use an in-memory SQLite
> database, and then squirrel the DB away with everything else in the
> application file.  That way, everything would be stored under one roof, so
> to speak.
>
> My question:  Is there a good way to "pickle" a SQLite database into a
> block of bytes for storage, and then "unpickle" it later for use?  My
> fantasy is that this could all be done in memory so the file system does
> not have to become involved.
>
> I feel like I am missing something obvious here, but can't quite come up
> with it.  Thanks for any ideas or suggestions.
>
> Randall.
>
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] "Pickling" an in-memory SQLite database.

2019-01-31 Thread Randall Smith
Hi, guys.

I have an application that allows me to embed a (potentially large) block of 
data into its application file at close, and read the block back on open.  It 
would be convenient and attractive for me, for a plugin I am writing for this 
application, to be able to use an in-memory SQLite database, and then squirrel 
the DB away with everything else in the application file.  That way, everything 
would be stored under one roof, so to speak.

My question:  Is there a good way to "pickle" a SQLite database into a block of 
bytes for storage, and then "unpickle" it later for use?  My fantasy is that 
this could all be done in memory so the file system does not have to become 
involved.

I feel like I am missing something obvious here, but can't quite come up with 
it.  Thanks for any ideas or suggestions.

Randall.

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users