{"id":51460980,"url":"https://github.com/sismicfr/python-db2sql","last_synced_at":"2026-07-06T05:30:26.972Z","repository":{"id":359398239,"uuid":"1245823279","full_name":"sismicfr/python-db2sql","owner":"sismicfr","description":"CLI tool to dump or migrate any database (SQLite, MySQL, MSSQL, PostgreSQL, Oracle) into PostgreSQL or MSSQL — with file dump and live migration modes.","archived":false,"fork":false,"pushed_at":"2026-06-04T21:30:01.000Z","size":278,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-04T21:32:23.638Z","etag":null,"topics":["cli","database","etl","migration","mysql","oracle","postgresql","python","sql","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sismicfr.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.rst","funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-21T15:36:32.000Z","updated_at":"2026-06-04T21:27:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sismicfr/python-db2sql","commit_stats":null,"previous_names":["sismicfr/python-db2sql"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sismicfr/python-db2sql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sismicfr%2Fpython-db2sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sismicfr%2Fpython-db2sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sismicfr%2Fpython-db2sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sismicfr%2Fpython-db2sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sismicfr","download_url":"https://codeload.github.com/sismicfr/python-db2sql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sismicfr%2Fpython-db2sql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35179683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-06T02:00:07.184Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cli","database","etl","migration","mysql","oracle","postgresql","python","sql","sqlite"],"created_at":"2026-07-06T05:30:23.797Z","updated_at":"2026-07-06T05:30:26.953Z","avatar_url":"https://github.com/sismicfr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"db2sql\n======\n\n|CI| |PyPI| |Read the Docs| |Coverage| |Python| |Code Style| |Pre-Commit| |License|\n\n``db2sql`` is a Python package providing a command-line utility to move any supported source database (SQLite, MySQL, MSSQL, PostgreSQL, Oracle) into a target dialect — PostgreSQL (default) or Microsoft SQL Server — selectable via ``--target``.\n\nTwo output modes are supported:\n\n* **Dump mode** (default) — write a SQL file (or stream to ``stdout``) that can later be replayed with ``psql -f`` or ``sqlcmd -i``.\n* **Migrate mode** — open a live connection to the target database and apply the same DDL and data directly, without an intermediate file. The DDL produced is byte-identical to dump mode: a single ``SqlEmitter`` is the source of truth in both paths.\n\n\nInstallation\n------------\n\n``db2sql`` is compatible with Python 3.9+.\n\nUse ``pip`` to install the latest stable version. Note the distribution name on PyPI is ``python-db2sql`` while the importable Python package is ``db2sql`` (same convention as ``python-dateutil``):\n\n.. code-block:: console\n\n   $ pip install --upgrade python-db2sql\n\nAfter installation, the CLI is available as ``db2sql`` and the importable module as ``db2sql``:\n\n.. code-block:: python\n\n   from db2sql.interface.cli import main\n\nThe current development version is available on `GitHub.com\n\u003chttps://github.com/sismicfr/python-db2sql\u003e`__ and can be installed directly from\nthe git repository:\n\n.. code-block:: console\n\n   $ pip install git+https://github.com/sismicfr/python-db2sql.git\n\n\nLive migration mode\n-------------------\n\nStream a source database directly into a live target — same DDL as the file\ndump, but without the round-trip through a ``.sql`` file:\n\n.. code-block:: console\n\n   # SQLite source → live Postgres target\n   $ db2sql --driver sqlite --dbname mydb.sqlite migrate \\\n       --target-host localhost --target-port 5432 \\\n       --target-dbname mytarget --target-user postgres --target-password s3cr3t\n\nThe ``migrate`` subcommand uses the ``SqlEmitter`` of the chosen ``--target``\nto produce DDL and a dialect-specific ``TargetWriter`` (e.g. ``psycopg2.copy``\nfor Postgres, batched ``executemany`` for MSSQL) to bulk-load rows. See the\n`CLI reference \u003chttps://python-db2sql.readthedocs.org/en/stable/cli.html#db2sql-migrate\u003e`__\nfor all ``--target-*`` flags and migration options (``--on-existing``,\n``--transaction-mode``, ``--batch-size``).\n\n\nReplayable dumps\n----------------\n\nBy default, the dump emits ``CREATE TABLE`` statements only — replaying the\nfile against a database that already contains the target tables fails. Pass\n``--on-existing drop`` (or set ``dump.on_existing: drop`` in the config) to\nprepend a ``DROP TABLE IF EXISTS`` for every table in reverse-dependency\norder:\n\n.. code-block:: console\n\n   $ db2sql --driver sqlite --dbname mydb.sqlite --on-existing drop -f dump.sql\n\nPass ``--on-existing truncate`` to produce a *data-only* script: no DDL is\nemitted, the dump just ``TRUNCATE``\\s every managed table and reloads its\nrows. Use it to refresh data into a pre-existing schema:\n\n.. code-block:: console\n\n   $ db2sql --driver sqlite --dbname mydb.sqlite --on-existing truncate -f refresh.sql\n\n\nValidating a configuration\n--------------------------\n\nBefore launching a long dump, check the configuration file and (optionally)\npreview the export plan without producing any SQL:\n\n.. code-block:: console\n\n   # syntax check + plugin name resolution (no DB connection)\n   $ db2sql validate db2sql.yml\n\n   # connect to the source and print the plan, no SQL emitted\n   $ db2sql validate db2sql.yml --dry-run\n\n   # same plan plus one SELECT COUNT(*) per kept table\n   $ db2sql validate db2sql.yml --dry-run --with-counts\n\nSee the `CLI reference \u003chttps://python-db2sql.readthedocs.org/en/stable/cli.html#db2sql-validate\u003e`__\nfor full details, exit codes, and the lookup order when the positional\n``CONFIG_FILE`` is omitted.\n\n\nExtensibility\n-------------\n\nBeyond the built-in drivers (SQLite, MySQL, MSSQL, PostgreSQL, Oracle) and\ntargets (PostgreSQL, MSSQL), ``db2sql`` discovers third-party plugins through\nthree `entry-point \u003chttps://packaging.python.org/en/latest/specifications/entry-points/\u003e`__\ngroups:\n\n* ``db2sql.readers`` — register a new source driver (``--driver``)\n* ``db2sql.emitters`` — register a new target dialect for the file dump (``--target``)\n* ``db2sql.writers`` — register a new target writer for live migration (used by ``db2sql migrate``)\n\nA step-by-step authoring guide lives in the\n`Plugins \u003chttps://python-db2sql.readthedocs.org/en/stable/plugins.html\u003e`__\nsection of the documentation, and three runnable example projects ship under\n`examples/ \u003chttps://github.com/sismicfr/python-db2sql/tree/main/examples\u003e`__:\n\n* ``examples/csv-producer`` — a custom reader (a directory of CSVs)\n* ``examples/sqlite-emitter`` — a custom emitter (SQLite-flavoured SQL)\n* ``examples/yaml-to-markdown`` — a single package that ships both a reader\n  and an emitter\n\nEach example is a standalone Python distribution: ``cd examples/\u003cname\u003e \u0026\u0026 pip install -e .``\nmakes its driver / target immediately usable from the ``db2sql`` CLI.\n\n\nBug reports\n-----------\n\nPlease report bugs and feature requests at\nhttps://github.com/sismicfr/python-db2sql/issues.\n\n\nDocumentation\n-------------\n\nThe full documentation for CLI and API is available on `readthedocs\n\u003chttp://python-db2sql.readthedocs.org/en/stable/\u003e`_.\n\nBuild the docs\n~~~~~~~~~~~~~~\n\nWe use ``tox`` to manage our environment and build the documentation::\n\n    pip install tox\n    tox -e docs\n\nContributing\n------------\n\nFor guidelines for contributing to ``db2sql``, refer to `CONTRIBUTING.rst \u003chttps://github.com/sismicfr/python-db2sql/blob/main/CONTRIBUTING.rst\u003e`_.\n\n\n.. |CI| image:: https://img.shields.io/github/actions/workflow/status/sismicfr/python-db2sql/ci.yml?branch=main\u0026label=CI\u0026logo=github\n   :target: https://github.com/sismicfr/python-db2sql/actions/workflows/ci.yml?query=branch%3Amain\n   :alt: CI status on main (Python 3.9–3.14 + functional)\n\n.. |PyPI| image:: https://img.shields.io/pypi/v/python-db2sql?label=PyPI\u0026logo=pypi\n   :target: https://badge.fury.io/py/python-db2sql\n   :alt: PyPI\n\n.. |Read the Docs| image:: https://img.shields.io/readthedocs/python-db2sql?label=Read%20the%20Docs\u0026logo=Read%20the%20Docs\n   :target: https://python-db2sql.readthedocs.org/en/latest\n   :alt: Docs\n\n.. |Coverage| image:: https://img.shields.io/codecov/c/github/sismicfr/python-db2sql?logo=Codecov\u0026label=Coverage\n   :target: https://codecov.io/github/sismicfr/python-db2sql?branch=main\n   :alt: Cover\n\n.. |Python| image:: https://img.shields.io/pypi/pyversions/python-db2sql.svg?label=Python\u0026logo=Python\n   :target: https://pypi.python.org/pypi/python-db2sql\n   :alt: Python\n\n.. |Code Style| image:: https://img.shields.io/badge/code%20style-black-000000.svg?label=Code%20Style\n   :target: https://github.com/python/black\n   :alt: Code Style\n\n.. |Pre-Commit| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026label=Pre-Commit\n   :target: https://github.com/pre-commit/pre-commit\n   :alt: Pre-Commit\n\n.. |License| image:: https://img.shields.io/github/license/sismicfr/python-db2sql?label=License\n   :target: https://github.com/sismicfr/python-db2sql/blob/main/COPYING\n   :alt: License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsismicfr%2Fpython-db2sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsismicfr%2Fpython-db2sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsismicfr%2Fpython-db2sql/lists"}