Standalone with SQLite and Mac

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

cbarbal
Posts: 114
Joined: Fri May 08, 2015 5:04 pm

Standalone with SQLite and Mac

Post by cbarbal » Thu Dec 13, 2018 2:48 pm

Hi all,

I have created three standalone with SQLite on a Mac. In Application Settings, in Copy Files,
1- I have not put anything.
2- I added the file
3- I have added the file and marked Copy Referenced Files

None works for me, it does not find the database. I get a message putting the Path and it's the right one.
Lloguers002.jpg

Code: Select all

command openConection
   put specialFolderPath("documents") into tDBPath
   put "/Lloguers.db" after tDBPath
   put revOpenDatabase("sqlite", tDBPath, , , , ) into gDBID
   if gDBID is not an integer then
      --      answer question "No s'ha pogut connectar amb la base de dades. Comprovi que existeixi." with "Sortir"
      answer question "Error - Unable to connect to the database" with "Exit"
   else
      hide button "btnConexio"
      show group "grpMenu"
   end if
   answer info "Current path:" && tDBPath with "OK"
end openConection
What do I do wrong?

Thanks in advance,

Carles

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Standalone with SQLite and Mac

Post by Klaus » Thu Dec 13, 2018 3:05 pm

Hi Carles,

1. In this case these lines:

Code: Select all

...
put specialFolderPath("documents") into tDBPath
put "/Lloguers.db" after tDBPath
put revOpenDatabase("sqlite", tDBPath, , , , ) into gDBID
...
will create a new and EMPTY database file in the Docs folder!

2. In this case the db file will be in -> specialfolderpath("resources")
However unless we are a user with ADMIN privileges, we are not allowed to WRITE (and merely OPEN a database file is considered WRITING!) in the APPLICATIONS folder.

In this case you need to copy the db file to the users Docs folder and open it from there like this, maybe "on openstack":

Code: Select all

...
## Add the db file via the "Copy files" tab in the standalone builder settings and then copy this file:
put specialfolderpath("resources") & "/Lloguers.db" into tSourceDB

## to the users Docs folder, wehre we defintively have WRITE permissions!
put specialfolderpath("documents") & "/Lloguers.db" into tTargetDB

## Check if db file is already present:
if there is NOT a file tTargetDB then
  put url("binfile:" & tSourceDB) into url("binfile:" & tTargetDB)
end if

## NOW you can open it from the Docs folder:
 put revOpenDatabase("sqlite", tTargetDB, , , , ) into gDBID
...
3. "Copy referenced files" will only work with referenced images and videos.


Best

Klaus

cbarbal
Posts: 114
Joined: Fri May 08, 2015 5:04 pm

Re: Standalone with SQLite and Mac

Post by cbarbal » Thu Dec 13, 2018 3:17 pm

Hi Klaus,

I'm doing the test on my own computer and I do not create a new copy. If I speak the original works perfectly and with no standalone. I'm sorry but I can not understand why you can not find it?

Regards,

Carles

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Standalone with SQLite and Mac

Post by Klaus » Thu Dec 13, 2018 3:37 pm

No# 3 is the way to go, been doing this for years!
Do you get any errors? Please check the result of the DB connection:

Code: Select all

...
if gDBID is not an integer then
      answer question "Error - Unable to connect to the database:" && CR & gDBID
end if
...
And see what the dialog says.

Another idea;
There are in fact problems with the standalone builder NOT copying neccessary externals like db driver to the standalone. So please check "Select inclusions for the stacnalone application" and select the neccessary inclusion on the "Inclusions" tab in the standalone builder settings.

cbarbal
Posts: 114
Joined: Fri May 08, 2015 5:04 pm

Re: Standalone with SQLite and Mac

Post by cbarbal » Thu Dec 13, 2018 4:25 pm

Hi Klaus,

The script is like this:

Code: Select all

command openConection
   ## Add the db file via the "Copy files" tab in the standalone builder settings and then copy this file:
   put specialfolderpath("resources") & "/Lloguers.db" into tSourceDB
   
   ## to the users Docs folder, wehre we defintively have WRITE permissions!
   put specialfolderpath("documents") & "/Lloguers.db" into tTargetDB
   
   ## Check if db file is already present:
   if there is NOT a file tTargetDB then
      put url("binfile:" & tSourceDB) into url("binfile:" & tTargetDB)
   end if
   
   ## NOW you can open it from the Docs folder:
   put revOpenDatabase("sqlite", tTargetDB, , , , ) into gDBID
   
   if gDBID is not an integer then
      --      answer question "No s'ha pogut connectar amb la base de dades. Comprovi que existeixi." with "Sortir"
      answer question "Error - Unable to connect to the database" with "Exit"
   else
      hide button "btnConexio"
      show group "grpMenu"
   end if
   answer info "Current path:" && tTargetDB && gDBID with "OK"
end openConection
I have checked "Select inclusions for the stacnalone application". I select Datagrid, Printing, SQLite I do the standalone leaving blank CopyFiles. I add in the message that I put the ID connection and do not put it. In short, it does not connect

More ideas :D

Carles

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Standalone with SQLite and Mac

Post by Klaus » Thu Dec 13, 2018 4:37 pm

Do you get an error? If yes, what does it say?
And please try this:

Code: Select all

...
if gDBID is not an integer then
      answer question "Error - Unable to connect to the database:" && CR & gDBID
end if
...
What does the dialog say?

So the db file is already present in your Docs folder, right?
Then please also try:

Code: Select all

...
put specialfolderpath("documents") & "/Lloguers.db" into tTargetDB
answer (there is a file tTargetDB)
## This should read TRUE then
...

cbarbal
Posts: 114
Joined: Fri May 08, 2015 5:04 pm

Re: Standalone with SQLite and Mac

Post by cbarbal » Thu Dec 13, 2018 5:10 pm

Hi Klaus,
Lloguers001.jpg
Lloguers002.jpg
Script_

Code: Select all

command openConection
   ## Add the db file via the "Copy files" tab in the standalone builder settings and then copy this file:
   put specialfolderpath("resources") & "/Lloguers.db" into tSourceDB
   
   ## to the users Docs folder, wehre we defintively have WRITE permissions!

   put specialfolderpath("documents") & "/Lloguers.db" into tTargetDB
   answer (there is a file tTargetDB)
   ## This should read TRUE then
   
   ## Check if db file is already present:
   if there is NOT a file tTargetDB then
      put url("binfile:" & tSourceDB) into url("binfile:" & tTargetDB)
   end if
   
   ## NOW you can open it from the Docs folder:
   put revOpenDatabase("sqlite", tTargetDB, , , , ) into gDBID
   
   if gDBID is not an integer then
      answer question "Error - Unable to connect to the database:" && CR & gDBID
   else
      hide button "btnConexio"
      show group "grpMenu"
   end if
end openConection
Carles

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Standalone with SQLite and Mac

Post by Klaus » Thu Dec 13, 2018 5:16 pm

Hm, everything looks good, except the fact that we do not see any error in the second dialog!?
I'm out of ideas in the moment...

If you like you can send me the stack and the DB file and I will take a look: klaus AT major-k.de

cbarbal
Posts: 114
Joined: Fri May 08, 2015 5:04 pm

Re: Standalone with SQLite and Mac

Post by cbarbal » Fri Dec 14, 2018 9:54 am

Hi Klaus,

In case you can help. I just made a standalone with ODBC and it works perfectly. The standalone settings have been the default ones.

Regards,

Carles

cbarbal
Posts: 114
Joined: Fri May 08, 2015 5:04 pm

[SOLVED]Re: Standalone with SQLite and Mac

Post by cbarbal » Fri Dec 14, 2018 4:46 pm

As Herr Doktor Klaus told me :D

There is something incompatible with the creation of the SQLite standalode, not with ODBC, on my Mac. I started from an external disk, with the same operating system but different programs, and it worked.

Now I have the problem with the reports that have to be passed from FileMaker to Livecode. According to Klaus, who has seen the originals
There is no report tool available for LC, I'm afraid, but you can do this with a lot of scripting.
Bad prospects.

Regards,

Carles

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Standalone with SQLite and Mac

Post by bogs » Fri Dec 14, 2018 5:27 pm

cbarbal wrote:
Fri Dec 14, 2018 4:46 pm
There is no report tool available for LC, I'm afraid, but you can do this with a lot of scripting.
Or, perhaps, a bit of copying...
Selection_001.png
Still included in 7.1.4, can be copied to the plugins folder...
Image

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Standalone with SQLite and Mac

Post by Klaus » Fri Dec 14, 2018 6:51 pm

No, that's not it! 8-)

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Standalone with SQLite and Mac

Post by bogs » Fri Dec 14, 2018 8:59 pm

No? Hm...
Selection_001.png
The survey says...
To display the report builder...
Note for people who started Lc after 7.x.x - This was changed after the 2.x series to the plugins folder, where it can be found up to v7.1.4.

It was removed in 8.x.x, however as far as I can tell, it *does* still work if dropped into the plugin folder :mrgreen:
Image

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Standalone with SQLite and Mac

Post by Klaus » Fri Dec 14, 2018 9:13 pm

bogs wrote:
Fri Dec 14, 2018 8:59 pm
No?
No! :D

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Standalone with SQLite and Mac

Post by bogs » Fri Dec 14, 2018 11:27 pm

Klaus wrote:
Fri Dec 14, 2018 9:13 pm
bogs wrote:
Fri Dec 14, 2018 8:59 pm
No?
No! :D
Hoooooookay :D :D
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”