App stopped seeing database

  1. 5 months ago

    Dean D

    Dec 18 Testers, Xojo Pro Santa Ynez California

    For several weeks, I have been working on a web app to run on a Raspberry Pi. I put both the compiled program and its SQLite database in the /home/pi/EZwithPi folder and everything worked fine until I uploaded a new version of the program to the rPi this morning. Since then I get a "Database not found" message when the session tries to connect to the database. If I run the program in the remote debugger it connects properly. I have been using this code for the connection:

    if TargetARM
      #if DebugBuild
       f = GetFolderItem("../")
      #Else
         f = GetFolderItem("")
      #Endif
    #Endif
    if f.exists Then  
      db.DatabaseFile = f.Child("EZPiData.sqlite")
      if not db.Connect then MsgBox "Could not connect to database"
    else
      MsgBox "Database not found"
    end if  

    Thinking the problem was with the GetFolderItem(""), I changed the code to

    f = SpecialFolder.UserHome.Child("EZwithPi")

    but that didn't work as it returned <root>/EZwithP/i instead of /home/pi/EZwithPi/ (I filed a bug report about that.) Next I hard coded it to

      f = GetFolderItem("/home/pi/EZwithPi")

    with exactly the same result as as GetFolderItem("").

    Neither starting the app with /etc/rc.local on boot up or starting it in Terminal works.

    Why does it work in the remote debugger (which is in a child of the app's folder) but not when compiled? Why has this worked for weeks without problem until today? Any update to the Pi operating system was automatic with no input from me and the code above goes back to the start of developing this app. Is there a work around other than moving the database to a different folder? Being a Linux newbie, there are probably better folders that the user home one.

    Any help with this will be most appreciated.

    Derk Jochems yesterday Pre-Release Testers, Xojo Pro

    The debugger is probably running as user "pi" but your application runs as "root" or you used sudo to execute.

    Be consistent use "pi" for both or "root" for both.

    Derk was right. All the problems went away after I assigned root execute permission to the folder with

    sudo chmod +x /home/pi/EZwithPi
  2. Javier M

    Dec 19 Xojo Inc, Testers, Xojo Pro, XDC Speakers, Third Party Store AprendeXojo - Europe, Spain

    Hi @Dean D

    Do you have some way to log where f is pointing to before the db.connect call? Maybe that would give you a hint about the problem.

  3. Derk J

    Dec 19 Testers, Xojo Pro

    The debugger is probably running as user "pi" but your application runs as "root" or you used sudo to execute.

    Be consistent use "pi" for both or "root" for both.

  4. Ivan T

    Dec 19 Testers

    @Dean D

    #if DebugBuild
       f = GetFolderItem("../")
      #Else
         f = GetFolderItem("")
      #Endif

    If a DebugBuild connects ok what happens if you remove the #If ?

    #if DebugBuild
       f = GetFolderItem("../")
  5. Dean D

    Dec 19 Testers, Xojo Pro Santa Ynez California

    After spending 4 hours trying to trouble shoot this problem this morning, I recompiled a version from three weeks ago and it runs fine with code unchanged in the areas I am having problems. By hard coding the path to the database rather than using GetFolderItem(""), I was able to verify the database was connecting and I could write to it, However the session never opened. I also found the program would write to the system log if I started it in the terminal with sudo, but if I started it with /etc/rc.local, nothing was written to the system log.

    The compiled version seems to be so buggy, I think it is time for us to decide whether to continue with the Raspberry Pi or switch to one of the small Windows boxes.

  6. Dean D

    Dec 20 Testers, Xojo Pro Answer Santa Ynez California

    Derk Jochems yesterday Pre-Release Testers, Xojo Pro

    The debugger is probably running as user "pi" but your application runs as "root" or you used sudo to execute.

    Be consistent use "pi" for both or "root" for both.

    Derk was right. All the problems went away after I assigned root execute permission to the folder with

    sudo chmod +x /home/pi/EZwithPi

or Sign Up to reply!