Page 1 of 1

sqlite in memory?

Posted: Tue May 03, 2011 10:47 pm
by jerico2day
Is it possible to create and use an sqlite database in memory? I found this thread:

http://www.purebasic.fr/english/viewtopic.php?t=27149

But the code no longer works and I can't wrap my head around it.

Re: sqlite in memory?

Posted: Tue May 03, 2011 10:59 pm
by ts-soft
use the native pb functions:

Code: Select all

UseSQLiteDatabase()

If OpenDatabase(0, ":memory:", "", "")
  If DatabaseUpdate(0, "CREATE TABLE info (test VARCHAR(255));")
    Debug "Table created"
  EndIf
EndIf
Here a more complete example

Re: sqlite in memory?

Posted: Wed May 04, 2011 3:43 am
by jerico2day
Ah wonderful. Thanks!

Re: sqlite in memory?

Posted: Wed May 04, 2011 10:04 am
by kinglestat
you can also set the temporary storage #PRAGMA to MEMORY and create your table in temp...eg CREATE TABLE temp.mytable.....

this way you can operate both ways ;) I have a post to this effect somewhere on the forum dont ask me where I am hopeless in navigating the web (and this forum in particular!)