Python lib and cli tool to convert MySQL schemas into BigQuery schemas
Convert MySQL schema (from a .sql
file) into a BigQuery-compatible schema in JSON format.
poetry
for dependency management. Ensure it’s installed.To convert a MySQL .sql
schema to a BigQuery JSON schema, use the convert.py
script:
poetry run python convert.py <path_to_sql_file> [options]
-o
, --output-path
: Specify the output path where the converted .json
file should be stored. By default, the output will be printed to the console. If specified, the output file will be named after the table, e.g., cool_table.json
.-t
, --extra-type-mappings
: Provide a path to a .json
file to extend and/or override default type mappings.-f
, --extra-field-mappings
: Provide a path to a .json
file to assign a specific type to a particular field.-d
, --drop-virtual-fields
: Set this flag to exclude virtual fields in the generated .json
schema.To validate the conversion, run the tests:
poetry run python test.py
The test_data
folder contains test cases and their expected outputs.
The default MySQL to BigQuery type mappings are in types_map.json
. If you need different mappings, you can use the -t
(or --extra-type-mappings
) and -f
(or --extra-field-mappings
) options.
SECURITY.md
.Licensed under the MIT License. Check out the LICENSE file.