SQLite: how to open existing database in memory

Peter Haworth pete at lcsql.com
Sat Oct 17 12:25:51 EDT 2015


Sorry, I should have looked at your syntax more closely.

You can't open an existing database as an in memory database.  If you want
to open an in memory database, the revopendatabase syntax is
revOpenDatabase("sqlite",":memory:") and it will be a brand new, empty
database with no tables.  The syntax you used would have created a disk
database file named /Users/Dev/Documents/Ratings.db3:memory: with no tables
in it, hence the error message you got.

Hope that explains it better.



Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>

On Sat, Oct 17, 2015 at 7:57 AM, Glen Bojsza <gbojsza at gmail.com> wrote:

> I think we have a disconnect...
>
> I want to open an existing database but in memory.
>
> You are saying that I opened a new database in memory but need to create
> tables in it.
>
> So I guess the question is better put:
>
> Can you open an existing base in memory if so how?
>
> If you can't open an existing database in memory then if you create a new
> one in memory can you copy the tables from an existing one into the
> database that is in memory?
>
> On Sat, Oct 17, 2015 at 10:36 AM, Peter Haworth <pete at lcsql.com> wrote:
>
> > You created a database but you didn't create any tables in it. You'll
> need
> > to issue a CREATE TABLE command after opening the db.
> >
> > On Sat, Oct 17, 2015, 7:22 AM Glen Bojsza <gbojsza at gmail.com> wrote:
> >
> > > I am trying to open an existing SQLite database in memory.
> > >
> > > When I do this (or think I do this) I get a database connection ID but
> > the
> > > it errors out when I try just to show the current data?
> > >
> > > On OS X Mavericks LC 8 DP4
> > >
> > > *on* mouseUp
> > >
> > >    *put* "/Users/Dev/Documents/Ratings.db3:memory:" into tDatabasePath
> > >
> > >    *put* revOpenDatabase("sqlite", tDatabasePath, , , , ) into
> > tDatabaseID
> > >
> > >    *put* "Connection = " & tDatabaseID  -- if I get an integer then a
> > > database connection has been made
> > >
> > >    *put "SELECT * from Movies" into tSQL*
> > >
> > >    *put* revDataFromQuery(tab,*return*,tDatabaseID,tSQL) into myresults
> > >
> > >    *put* myresults
> > >
> > >    revCloseDataBase tDatabaseID
> > >
> > > *end* mouseUp
> > >
> > >
> > > My output:
> > >
> > > Connection = 1         (shows I have a database connection)
> > >
> > > revdberr,Database Error: no such table: Movies
> > >
> > >
> > > Any suggestions?
> > >
> > > thanks,
> > >
> > > Glen
> > > _______________________________________________
> > > use-livecode mailing list
> > > use-livecode at lists.runrev.com
> > > Please visit this url to subscribe, unsubscribe and manage your
> > > subscription preferences:
> > > http://lists.runrev.com/mailman/listinfo/use-livecode
> > >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list