The Synth MySQL integration is currently in beta.
synth can use MySQL as a data source or
synth to a MySQL is as simple as specifying a URI
and schema during the
One quirk with the current MySQL integration is that the host can't be represented in IPv4, so DNS or IPv6 representations should be used instead. If IPv4 compatibility is wanted, use IPv4-mapped IPv6.
synth can import directly from a MySQL
database and create a data model from the database schema. During import, a
will be created from your database schema, and
a collection is created for each
table in a separate JSON file.
synth will map database columns to fields in
the collections it creates. It then provides default generators for every
collection. Synth will default to the
public schema but this can be
overriden with the
synth will automatically detect primary key and foreign key constraints at
import time and update the namespace and collection to reflect them. Primary
keys get mapped to
generator, and foreign keys get mapped to the same_as
synth will sample data randomly from every table in order to create a
more realistic data model by automatically inferring bounds on types.
synth has its own internal data model, and so does MySQL, therefore a
conversion occurs between
synth types and MySQL types. The inferred type
can be seen below. The synth types link to default generator variant
generated during the
import process for that PostgreSQL type.
Note, not all MySQL types have been covered yet. If there is a type you need, open an issue on GitHub.
|MySQL Type||Synth Type|
### Example Import Command ```bashsynth import --from mysql://user:pass@localhost:5432/postgres --schemamain my_namespace
synth can generate data directly into your MySQL database. First
will generate as much data as required, then open a connection to your database,
and then perform batch insert to quickly insert as much data as you need.
synth will also respect primary key and foreign key constraints, by performing
a topological sort on the
data and inserting it in the right order such that no constraints are violated.
synth generate --to mysql://user:pass@localhost:5432/ --schemamain my_namespace