Cloning a SQLite (or any SQL) database

Kay C Lan lan.kc.macmail at gmail.com
Mon May 23 02:04:22 EDT 2016


On Mon, May 23, 2016 at 4:46 AM, Paul Dupuis <paul at researchware.com> wrote:
> this app may use MySQL (or someday, possible other flavors of
> SQL database) and I'd like to have a generalized routine that just
> relies on LiveCode and "standard" SQL commands.
>
If you are using MySQL why not have a look at DUMP. This is not an SQL
command, but it's accessible from LC as a shell command> mysqldump
[options] --db_name

https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html

The output is very human (LC) readable and includes ALL the standard
SQL commands used to create/define the db/tables. So it's relatively
easy in LC to parse the output and grab those commands, send them to
LC's revExecuteSQL to recreate the db from scratch.

If memory serves me I think the only limitation is you must be doing
this on the same machine as the MySQL server, you can't do it over a
network connection.

I believe SQLite's '.dump' command is very similar to DUMP:

https://www.sqlite.org/cli.html#section_10

Either way, both of these approaches will give you a text file that
allows you to rebuild your DB in any flavour of DB that recognises
SQL.

HTH




More information about the use-livecode mailing list