All Projects β†’ simonw β†’ Db To Sqlite

simonw / Db To Sqlite

Licence: apache-2.0
CLI tool for exporting tables or queries from any SQL database to a SQLite file

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Db To Sqlite

Databases
Async database support for Python. πŸ—„
Stars: ✭ 2,602 (+1088.13%)
Mutual labels:  sqlalchemy, sqlite
Apollo
A basic Application with multiple functionalities built with FastAPI aim to help Users Buy New Items Provided using PaypalAPI πŸš€
Stars: ✭ 22 (-89.95%)
Mutual labels:  sqlalchemy, sqlite
nim-gatabase
Connection-Pooling Compile-Time ORM for Nim
Stars: ✭ 103 (-52.97%)
Mutual labels:  sqlalchemy, sqlite
Choochoo
Training Diary
Stars: ✭ 186 (-15.07%)
Mutual labels:  sqlalchemy, sqlite
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 2,315 (+957.08%)
Mutual labels:  sqlite
Better Sqlite3
The fastest and simplest library for SQLite3 in Node.js.
Stars: ✭ 2,778 (+1168.49%)
Mutual labels:  sqlite
Trilogy
TypeScript SQLite layer with support for both native C++ & pure JavaScript drivers.
Stars: ✭ 195 (-10.96%)
Mutual labels:  sqlite
Geopackage Js
GeoPackage JavaScript Library
Stars: ✭ 191 (-12.79%)
Mutual labels:  sqlite
Scout
RESTful search server written in Python, powered by SQLite.
Stars: ✭ 213 (-2.74%)
Mutual labels:  sqlite
Ionic Starter Template
Reinventing the wheel, again! Sorry Ionic Team... but there are many newbies learning on Youtube!
Stars: ✭ 208 (-5.02%)
Mutual labels:  sqlite
Rustorm
an orm for rust
Stars: ✭ 205 (-6.39%)
Mutual labels:  sqlite
Ok ip proxy pool
πŸΏηˆ¬θ™«δ»£η†IPζ± (proxy pool) pythonπŸŸδΈ€δΈͺ还okηš„IP代理池
Stars: ✭ 196 (-10.5%)
Mutual labels:  sqlite
Aioodbc
aioodbc - is a library for accessing a ODBC databases from the asyncio
Stars: ✭ 206 (-5.94%)
Mutual labels:  sqlite
Awesome Sqlalchemy
A curated list of awesome tools for SQLAlchemy
Stars: ✭ 2,316 (+957.53%)
Mutual labels:  sqlalchemy
Dqlite
Embeddable, replicated and fault tolerant SQL engine.
Stars: ✭ 2,644 (+1107.31%)
Mutual labels:  sqlite
Norm
A Nim ORM
Stars: ✭ 193 (-11.87%)
Mutual labels:  sqlite
Twitter To Sqlite
Save data from Twitter to a SQLite database
Stars: ✭ 203 (-7.31%)
Mutual labels:  sqlite
Endb
Key-value storage for multiple databases. Supports MongoDB, MySQL, Postgres, Redis, and SQLite.
Stars: ✭ 208 (-5.02%)
Mutual labels:  sqlite
Askgit
Query git repositories with SQL. Generate reports, perform status checks, analyze codebases. πŸ” πŸ“Š
Stars: ✭ 2,707 (+1136.07%)
Mutual labels:  sqlite
Express Graphql Boilerplate
Express GraphQL API with JWT Authentication and support for sqlite, mysql, and postgresql
Stars: ✭ 201 (-8.22%)
Mutual labels:  sqlite

db-to-sqlite

PyPI Changelog Travis CI License

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]'

Installing the mysqlclient library on OS X can be tricky - I've found this recipe to work (run that before installing db-to-sqlite).

For PostgreSQL, use this:

pip install 'db-to-sqlite[postgresql]'

Usage

Usage: db-to-sqlite [OPTIONS] CONNECTION PATH

  Load data from any database into SQLite.

  PATH is a path to the SQLite file to create, e.c. /tmp/my_database.db

  CONNECTION is a SQLAlchemy connection string, for example:

      postgresql://localhost/my_database
      postgresql://username:[email protected]/my_database

      mysql://[email protected]/my_database
      mysql://username:[email protected]/my_database

  More: https://docs.sqlalchemy.org/en/13/core/engines.html#database-urls

Options:
  --version                     Show the version and exit.
  --all                         Detect and copy all tables
  --table TEXT                  Specific tables to copy
  --skip TEXT                   When using --all skip these tables
  --redact TEXT...              (table, column) pairs to redact with ***
  --sql TEXT                    Optional SQL query to run
  --output TEXT                 Table in which to save --sql query results
  --pk TEXT                     Optional column to use as a primary key
  --index-fks / --no-index-fks  Should foreign keys have indexes? Default on
  -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 "postgresql://localhost/myblog" blog.db \
    --table=blog_entry

You can specify --table more than once.

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 "postgresql://localhost/myblog" blog.db \
    --all

When running --all you can specify tables to skip using --skip:

db-to-sqlite "postgresql://localhost/myblog" blog.db \
    --all \
    --skip=django_migrations

If you want to save the results of a custom SQL query, do this:

db-to-sqlite "postgresql://localhost/myblog" output.db \
    --output=query_results \
    --sql="select id, title, created from blog_entry" \
    --pk=id

The --output option specifies the table that should contain the results of the query.

Using db-to-sqlite with Heroku Postgres

If you run an application on Heroku using their Postgres database product, you can use the heroku config command to access a compatible connection string:

$ heroku config --app myappname | grep HEROKU_POSTG
HEROKU_POSTGRESQL_OLIVE_URL: postgres://username:[email protected]:5432/dbname

You can pass this to db-to-sqlite to create a local SQLite database with the data from your Heroku instance.

You can even do this using a bash one-liner:

$ db-to-sqlite $(heroku config --app myappname | grep HEROKU_POSTG | cut -d: -f 2-) \
    /tmp/heroku.db --all -p
1/23: django_migrations
...
17/23: blog_blogmark
[####################################]  100%
...

Related projects

  • Datasette: A tool for exploring and publishing data. Works great with SQLite files generated using db-to-sqlite.
  • sqlite-utils: Python CLI utility and library for manipulating SQLite databases.
  • csvs-to-sqlite: Convert CSV files into a SQLite database.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].