[Gambas-user] Sqlite

Bruce adamnt42 at gmail.com
Sat Mar 20 17:26:02 CET 2021


>> El 19/3/21 a las 7:39, Shane escribió:
>>> HI Group I have this code
>>>
>>>               Try Con.Close()
>>>                     Con.Type = "sqlite3"
>>>                     Con.Host = "./"
>>>                     Con.Name = "voc.sqlite3"
>>>                     Con.Open()
>>>                      Print "Connected : " & Con.Opened
>>>
>>> this works fine in the editor but when i make a Deb of this and run it
>>> tells me it can not find the file
>>>
>>> any ideas
>>>
>>> cheers shane
>>>

shane,

What the well meaning people are trying to tell you is that you are 
using a "relative" path when you absolutely should not be. See 
http://gambaswiki.org/wiki/cat/path in the Language Overviews part of 
the wiki.

Inside the IDE ./ is pointing to the project directory. Where, of 
course, your voc.sqlite3 file exists. However at runtime this points 
"inside" the compressed executable archive. Your voc.sqlite "file" does 
exist in that archive but only at a stretch of munged bytes.

The runtime and therfore your program can access that chunk of data, 
interpret it as a file and store it somewhere using normal Gambas file 
handling commands. So you can copy that sqlite file out of your program 
and then access THAT file via the Gambas DB component.

But the sqlite "server/driver" library, libsqlite3 or whatever cannot 
see inside your executable. Thus error "File does not exist" occurs,

Now, you need also to consider this, By placing the database file inside 
the executable, you have made it read only. As obviously it cannot be 
written back inside the executable file.If you want it to be updateable 
then you will need to set it up in SOME persistent writeable directory 
somewhere (not necessarily the User.Home directory.

If it IS read-only data then I suggest that it it copied out of the 
executable into the /tmp/gambbas.uid area using the Gambas Temp 
functions. That way you get automatic cleanup and a few other benefits.

rgrds
bruce


More information about the User mailing list