SQLite: how to open existing database in memory

Bob Sneidar bobsneidar at iotecdigital.com
Wed Oct 21 11:27:49 EDT 2015


Whaa? There is an ATTACH command?? I will look into this. Sounds like something I might be able to use at some point. 

Bob S


> On Oct 17, 2015, at 11:56 , Peter Haworth <pete at lcsql.com> wrote:
> 
> I assume this is a single user application?  When you say you want to make
> changes to the database, do you mean the user makes changes to the data in
> the database using your application?  If the disk version never changes
> then the next time the user runs your app, whatever changes they made last
> time around will be gone - is that OK?
> 
> I'm not totally sure what you mean by "look into the database" but assume
> you mean using anything other than your application.  There's always going
> to be ways to do that using any of the sqlite admin programs out there,
> unless you use one of the encryption add-ons for sqlite.
> 
> If you want to continue down this path, then conceptually, here's one way
> to get the disk based db into an in memory version.
> 
> 1.  Open the in memory database which will be completely empty.
> 2.  Use the ATTACH command to open the disk db over the same connection.
> Doing that involves assigning a name to identify the db which I'll assume
> is "diskdb".  You'll use that in the next step.
> 3. For each table in the disk db, issue a CREATE TABLE AS command, which
> will look something like this:  "CREATE main.TABLE Movies AS SELECT * FROM
> diskdb.Movies"
> 4. Issue the command DETACH DATABASE diskdb
> 
> After that all your data will be in your in memory database and you can
> access it just as in any other db.
> 
> Pete





More information about the use-livecode mailing list