How do I open an in-memory database file into sqlite3
Asked Answered
C

1

13

I'm on a system with no access to disk. My C program has in memory the contents of a valid, small, sqlite3 file (received over the network). I would like to use sqlite3's C API to open and access this file (read-only is fine).

How do I do this? I know I can create an empty in-memory database with

sqlite3_open(":memory:", &foo)

but is there any way to open my existing db? I don't have the privileges to create a ram disk, but perhaps something along those lines? Thanks.

Cacus answered 7/5, 2009 at 21:9 Comment(0)
S
11

Code example here (in C):

http://www.mail-archive.com/[email protected]/msg15929.html

Shanley answered 7/5, 2009 at 21:27 Comment(4)
That was useful, although (for anybody else reading this later), the actual code is in: mail-archive.com/[email protected]/msg15905.html I unfortunately won't actually be able to use this as my program is really in python (running on the "google app engine", which doesn't allow C extensions) using python's interface to sqlite... I used C in my question to try to simplify the issue. Thanks.Cacus
update 2: apparently the google app engine's python environment doesn't even have the sqlite3 module, so the motivation behind my original question was pointlessCacus
Why would you explicitly say, "I would like to use sqlite3's C API" when you are using Python?Beacham
Because anything done in python would also be possible in C and not vice-versa? I knew this was a long-shot so I wanted to cast as wide a net as possible. The C solution might still come in handy to me in the future.Cacus

© 2022 - 2024 — McMap. All rights reserved.