CLI tool for exporting tables or queries from any SQL database to a SQLite file
Project description
db-to-sqlite
CLI tool for exporting tables or queries from any SQL database to a SQLite file.
Installation
Install from PyPI like so:
pip install db-to-sqlite
If you want to use it with MySQL, you can install the extra dependency like this:
pip install db-to-sqlite[mysql]
For PostgreSQL, use this:
pip install db-to-sqlite[postgresql]
Usage
Usage: db-to-sqlite [OPTIONS] PATH
Load data from any database into SQLite.
https://github.com/simonw/db-to-sqlite
Options:
--version Show the version and exit.
--connection TEXT SQLAlchemy connection string [required]
--all Detect and copy all tables
--table TEXT Name of table to save the results (and copy)
--skip TEXT When using --all skip these tables
--sql TEXT Optional SQL query to run
--pk TEXT Optional column to use as a primary key
-p, --progress Show progress bar
--help Show this message and exit.
For example, to save the content of the blog_entry
table from a PostgreSQL database to a local file called blog.db
you could do this:
db-to-sqlite blog.db \
--connection="postgresql://localhost/myblog" \
--table=blog_entry
You can also save the data from all of your tables, effectively creating a SQLite copy of your entire database. Any foreign key relationships will be detected and added to the SQLite database. For example:
db-to-sqlite blog.db \
--connection="postgresql://localhost/myblog" \
--all
When running --all
you can specify tables to skip using --skip
:
db-to-sqlite blog.db \
--connection="postgresql://localhost/myblog" \
--all \
--skip=django_migrations
If you want to save the results of a custom SQL query, do this:
db-to-sqlite output.db \
--connection="postgresql://localhost/myblog" \
--table=query_results \
--sql="select id, title, created from blog_entry" \
--pk=id
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for db_to_sqlite-0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c43a9a2abc2d41d8c1e588a0bd057221ccc4b7303e8098d9193033c7f12534d8 |
|
MD5 | af481e38eb063c6c6441b3b04191af51 |
|
BLAKE2b-256 | 89f4dd6344dc3fa4083a0fbb924d21101bea89ecc71e9859c4f890c9edb4e449 |