Page 1 of 1

What is the best way to replicate MySQL DB structure to SQLite DB?

Posted: 07.08.2021, 12:34
by Yogi Yang
Hello,

Are there any possibilities of being able to replicate the structure of a remote MySQL database to a local SQLite database?

TIA

Re: What is the best way to replicate MySQL DB structure to SQLite DB?

Posted: 07.08.2021, 21:35
by marsupilami
No - you would have to write something like this yourself. Read the MySQL structure using a ZSQLMetaData object and then generate SQLite statements for creating database objects.

Re: What is the best way to replicate MySQL DB structure to SQLite DB?

Posted: 09.08.2021, 07:25
by Yogi Yang
Thanks for the hint.

I will try that out.

Re: What is the best way to replicate MySQL DB structure to SQLite DB?

Posted: 09.08.2021, 09:36
by aehimself
Zeos itself will not provide you a component which dumps and recreates database layouts. As Jan said you can manually achieve this by using TZMetaData - just list all fields, indexes, constraints, etc.
You'll have to manually convert field types and assemble the create script in a syntax the target RDBMS accepts, though.

There are DB converter tools out in the wild but my personal experience is that
1, Even between major RDBMSes (I tried Microsoft's own MySQL -> MSSQL) the conversion is complicated, slow and sometimes unreliable
2, None of the usable ones are free
So while you can give a shot to look for a tool, I highly doubt you'll find one.

What you have to consider - does it really worth to put your time creating such a tool? I never tried but sounds complex to me. When I was in this situation it was easier to recreate the schema by hand and set up a Zeos script to copy the data.
I'd be really happy though if a free, easy to use multi-database migrator would exist. Especially if it's built upon Zeos :)