{"id":22398666,"url":"https://github.com/wallneradam/python_sql_schema_sync","last_synced_at":"2026-05-05T17:33:20.596Z","repository":{"id":67438895,"uuid":"210787867","full_name":"wallneradam/python_sql_schema_sync","owner":"wallneradam","description":"Generates SQL queries to make source table schema the same as destination table","archived":false,"fork":false,"pushed_at":"2023-01-31T13:44:26.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-11T01:43:13.220Z","etag":null,"topics":["mariadb","mysql","python","python3","schema","sql","synchronization"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wallneradam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-25T07:56:06.000Z","updated_at":"2023-05-08T12:47:34.000Z","dependencies_parsed_at":"2023-04-30T17:09:42.152Z","dependency_job_id":null,"html_url":"https://github.com/wallneradam/python_sql_schema_sync","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/wallneradam/python_sql_schema_sync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallneradam%2Fpython_sql_schema_sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallneradam%2Fpython_sql_schema_sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallneradam%2Fpython_sql_schema_sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallneradam%2Fpython_sql_schema_sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wallneradam","download_url":"https://codeload.github.com/wallneradam/python_sql_schema_sync/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallneradam%2Fpython_sql_schema_sync/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32660348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mariadb","mysql","python","python3","schema","sql","synchronization"],"created_at":"2024-12-05T07:11:43.854Z","updated_at":"2026-05-05T17:33:20.580Z","avatar_url":"https://github.com/wallneradam.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python SQL Schema Sync\nGenerates SQL queries to make source table schema the same as destination table.\n\nNow it is only understand MySQL/MariaDB dialect. But it should not be too hard to implement for\nother DBs like Postgres or SQLite.\n\n**Important!!**\nIt cannot handle table or field renames, these will create a DROP and CREATE/ADD queries. So after renames data loss will occur.\n\n## Features\n\n- \"AUTO INCREMENT\" values can be ommitted by parameter\n- \"IF NOT EXISTS\" can be removed or forced to be added by parameters\n- Fields updates are come befero keys, to be sure fields are specified\n- Actions (CREATE, DROP, ADD, MODIFY, REMOVE) can be filtered. This is good for preventing data loss\nwhen fields/tables are renamed\n- The result can be a string of sequential SQL or a list of SQL queries\n\n### Not implemented\n\n- Field orders are not taken into account (anyway storage order does not matter, I think)\n- It cannot detect field/table renames. I don't know a sure way to detect it.\n\n# How to use\n\n```python\nimport schema_sync\n\nsql1 = \"\"\"CREATE TABLE `test` (\n  `id` int(11) NOT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\nCREATE TABLE `user` (\n  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n  `full_name` varchar(255) NOT NULL,\n  `email` varchar(255) NOT NULL,\n  `created_at` datetime(6) NOT NULL,\n  `modified` DATETIME(6) NOT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `email` (`email`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;\n\"\"\"\n\nsql2 = \"\"\"CREATE TABLE `user` (\n    `id` BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,\n    `full_name` VARCHAR(255) NOT NULL,\n    `email` VARCHAR(255) NOT NULL UNIQUE,\n    `test` BOOL NOT NULL,\n    `created_at` DATETIME(6) NOT NULL,\n    `modified_at` DATETIME(6) NOT NULL\n) CHARACTER SET utf8mb4;\n\"\"\"\n\nprint(schema_sync.sync(sql1, sql2))\n# DROP TABLE `test`;\n# ALTER TABLE `user` ADD `modified_at` DATETIME(6) NOT NULL;\n# ALTER TABLE `user` ADD `test` BOOL NOT NULL;\n# ALTER TABLE `user` DROP `modified`;\n\nprint(schema_sync.sync(sql2, sql1))\n# ALTER TABLE `user` ADD `modified` DATETIME(6) NOT NULL;\n# CREATE TABLE IF NOT EXISTS `test` (\n#   `id` int(11) NOT NULL,\n#   PRIMARY KEY (`id`)\n# ) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n# ALTER TABLE `user` DROP `modified_at`;\n# ALTER TABLE `user` DROP `test`;\n\nprint(schema_sync.sync(sql1, sql2,\n                       allowed_actions=(ActionTypes.add,\n                                        ActionTypes.create,\n                                        ActionTypes.modify)))\n# ALTER TABLE `user` ADD `modified_at` DATETIME(6) NOT NULL;\n# ALTER TABLE `user` ADD `test` BOOL NOT NULL;\n\n\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwallneradam%2Fpython_sql_schema_sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwallneradam%2Fpython_sql_schema_sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwallneradam%2Fpython_sql_schema_sync/lists"}