SQLite db generates and then disappears after application shutdown

I’m getting familiar with the database class and using the sample code provided on the documentation.xojo.com for connecting to the sqlite engine and building a .sqlite database with a basic table.

This works great. I can see the file generate on my system but after I stop the application the database file disappears.

What do I need to do to commit the file to my system so I can access it later?

Side note: I am using the non-licensed xojo. From my reading I should be able to generate sqlite databases and eventually when the time comes I can get the database license to communicate with more engines.

Thanks.

ummm nothing
Should be no more complicated than the examples

Dim db As New SQLiteDatabase db.DatabaseFile = GetFolderItem("db.sqlite") If Not db.CreateDatabaseFile Then //handle error here End If
If the file is successfully created it should not disappear - personally I’ve never seen it disappear unless I deleted it or wrote code to delete it

I run the web app… I press a button with action event containing sample sqlite code from the documentation.xojo.com , Database is created successfully.

I look my system for the generated sqlite database. It should be “MyDB.sqlite”.

I am able to find this file while the app is running inside my projects working directory under a folder called “DebugMyAppName”.

Inside this folder contains the database file.

I stop the web app. Now the entire folder “DebugMyAppName” with the database is gone.

What folder should I be looking at for the stored database. The only place I find it generated is in a temporary Debug folder that Xojo creates when I run the project.

FYI: I’m using Ubuntu 12.04. I doubt that should matter.

Thanks.

Make sure you’re not writing it into the debug folder. The entire folder goes away.

@Tim Hare , You just hit the nail on the head…

however, where do i set the database to get stored to the project folder and not a temporary debug folder? Xojo Preferences?

So you’re probably doing something like

f = GetFolderItem(“blah”)

Change that to

f = GetFolderItem("").Parent.Child(“blah”)

Yeah I was using the sample code snippet from the docs site…

I just updated that code snippet with your suggestion… except I think its good to keep the *.sqlite extension.

dim dbFile as New FolderItem
dbFile = GetFolderItem("").Parent.Child(“MyDB.sqlite”)

Anyway, I think Xojo docs site should possible be updated with a note related to this. Other people might get a bit confused when they are testing out that snippet and the db is dropping into the debug folder and then vanishing. Just a suggestion.

Thanks again for your help!

It’s not a “language reference” sort of thing.
The language reference is “heres how you call this” or “heres how you can use the class”.
You won’t learn a lot about Xojo if you only refer to the language reference (online or local)

There’s a ton of other documentation in the “Documentation” directory right next to the installed IDE (and accessible from the Help Menu) I’d hazard a guess it’s already covered in the Frameworks book about Debugging & profiling if it’s anywhere.

@Norman Palardy yes makes sense :slight_smile: