sqlite in linux

Hi,

I don’t know if this problem was already raised, but I’m hoping for somebody help.

I am using Windows 10 for my xojo development.
I had an SQLite database that resided on my local pc [quote]c:\myapp\db\data1.db[/quote]
I can successfully open it on my xojo web app thru GetFolderItem("").Parent.Child(“db”).child(“data1.db”)

I got problem with this after uploading it to my host server. The [quote] GetFolderItem("").Parent.Child(“db”).child(“data1.db”) [/quote] seems return BLANK string.

Your help is very much appreciated.

If you move the database to the server than that path is no longer valid
the path you specified basically says “the location of my file is the PARENT_OF_THE_APP/DB/Data1.db”
which is a folder called DB in the same folder as the application is.

But if the app is now on the CLIENT, and the database is on the SERVER… the path is going to be more complicated
SERVER://SomeVolumen/someDirectory/data.db1

the problem is not with Xojo, but with you not quite understanding how the path structure works

Hi Dave,

Thanks for your reply.

Since my application is a XOJO WEB, how to reference the database located on “DB” folder, adjacent with the myapp.cgi?

Just curious: how is this related to linux ?

The host computer is a linux

Thus my question.

[quote=340895:@ronaldo florendo]Hi Dave,

Thanks for your reply.

Since my application is a XOJO WEB, how to reference the database located on “DB” folder, adjacent with the myapp.cgi?[/quote]
Technically you could just take out the Parent from your call. That said, I don’t suggest leaving it there. Someone crafty may find your database and download it directly. Usually databases are stored outside of the hosted path.

Thanks Greg,

Can you please guide me on how to reference the path of my SQLite database in Linux thru xojo code?

I would put the database in the Shared Documents folder - the path will look something like this:

Dim keyFile as FolderItem = SpecialFolder.SharedDocuments.child(“FilesForMyApp”).child(“databasefile”)

[quote=340954:@Jason Parsley]I would put the database in the Shared Documents folder - the path will look something like this:

Dim keyFile as FolderItem = SpecialFolder.SharedDocuments.child(“FilesForMyApp”).child(“databasefile”)[/quote]
but that assumes the app and database are on the same computer
he inferred the database was moved to a remote server

[quote=340955:@Dave S]but that assumes the app and database are on the same computer
he inferred the database was moved to a remote server[/quote]

I may have misunderstood then.

jason, your correct. My web app is at the same machine in a linux host server.

I had problem opening it.

I can do it in my local pc since Im using Windows 10. But when I uploaded it to Linux, my app crash because it cannot find the sqlite database.

Maybe:

#If TargetLinux // place here the Linux “path”

// Then in #Else, put the Windows Path
// #Else
#EndIf

Are you checking nil and .exists in your code? If those don’t show any problem, I would place a text file in Shared Documents and see if your code can open it.

How to path the file in linux? is it “/” or “”?
Also, it seems there is no DRIVE letter in linux host server. Unlike in windows, I can easily put getfolderitem(“c:\db\1.db”). How about in linux?

Hello,
you could also try to replace this line

GetFolderItem("").Parent.Child("db").child("data1.db")

with the following code, to see where the problem occurs:

[code]
dim f as FolderItem

f = GetFolderItem("")
if (f = nil) OR (f.Exists = FALSE) then
MsgBox(“Error 1”)
Return
else
MsgBox(f.NativePath)
end if

f = f.Parent
if (f = nil) OR (f.Exists = FALSE) then
MsgBox(“Error 2”)
Return
else
MsgBox(f.NativePath)
end if

f = f.Child(“db”)
if (f = nil) OR (f.Exists = FALSE) then
MsgBox(“Error 3”)
Return
else
MsgBox(f.NativePath)
end if

f = f.Child(“data1.db”)
if (f = nil) OR (f.Exists = FALSE) then
MsgBox(“Error 4”)
Return
else
MsgBox(f.NativePath)
end if[/code]

[quote=341050:@ronaldo florendo]How to path the file in linux? is it “/” or “”?
Also, it seems there is no DRIVE letter in linux host server. Unlike in windows, I can easily put getfolderitem(“c:\db\1.db”). How about in linux?[/quote]
It might be worth it for you to set up a Linux VM (free using Virtual Box) on your Windows machine so you can play around with Linux more to get a feel for it. It can be quite different from Windows. This will also give you a way to Remote Debug to help you troubleshoot more easily. Then once you are comfortable with your app running on the Linux VM, you’ll probably find that getting it up and running on your Linux server might be more straightforward.

Linux uses “/” as the path separator and does not use drive letters (it uses volumes). You can use the Volume command in Xojo to get at a specific volume, but in most cases you’ll want to put the file in a common location where you have permissions to access it and then use SpecialFolder (like Jason describes) to get a FolderItem to it.

Thank to you Guys!

I finally figure out how the folderitem works with Linux (which I’m not familiar with) . Thanks to Christian Mezes for giving me direct answer with his simple sample code.

It really work!