Livecodescript and MySQL

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Livecodescript and MySQL

Post by MaxV » Thu Jul 17, 2025 4:29 pm

I'm trying to use a pure livecode script (file.livecodescript) to access to a MySQL database, but it doesn't work outside the Livecode IDE.

I launch the the script this way:

Code: Select all

/opt/livecode/livecode.x86_64  -ui  /home/max/file.livecodescript
and I get error the line with revOpenDatabase function. Probably the script can't reach the database drivers.

How can I solve this? Where I should put the database drivers? I tried in many places without success.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

stam
Posts: 3074
Joined: Sun Jun 04, 2006 9:39 pm

Re: Livecodescript and MySQL

Post by stam » Thu Jul 17, 2025 5:36 pm

MaxV wrote:
Thu Jul 17, 2025 4:29 pm
I'm trying to use a pure livecode script (file.livecodescript) to access to a MySQL database, but it doesn't work outside the Livecode IDE.

I launch the the script this way:

Code: Select all

/opt/livecode/livecode.x86_64  -ui  /home/max/file.livecodescript
and I get error the line with revOpenDatabase function. Probably the script can't reach the database drivers.

How can I solve this? Where I should put the database drivers? I tried in many places without success.
Probably worth mentioning what OS (linux?) and what LC version?

Not sure it's a driver issue.
If it runs in the IDE (I presume you as a GUI stack), then attempting to run the IDE as console app may be the issue, or at least that's I what I rightly or wrongly understood from your code.

An app may need to be built and run as console app with the "-ui" flag, and when building you'd include the db driver as per normal and just have the app load your scriptOnlyStack as a library.
Although I may just be making stuff up...

Another way to run livecode script from the command line would be with livecode server, which includes the DB drivers, and does work although you'd probably need to modify your text file to encapsulate LC code with "<?lc" and "?>" tags.

Code: Select all

$ livecode-server myscript.lc
That seems like a better way to run a stack directly from the command line, but again, I may just be making stuff up...

garfield2
Posts: 4
Joined: Thu Jul 31, 2025 7:50 pm

Re: Livecodescript and MySQL

Post by garfield2 » Wed Aug 13, 2025 8:16 pm

You might be right that it’s not a driver location problem.
When running outside the IDE, the standalone engine needs to have the database library included at build time. If you just point the engine to a .livecodescript file, it won’t automatically load the MySQL driver.

One option is to build a small console standalone with the database library included, then load your script as a library from that.
Alternatively, using LiveCode Server (as you said) works because it already bundles the DB drivers, but the script would need the <?lc … ?> wrappers.

Post Reply