
Using db-to-sqlite with PostgreSQL schemas The -output option specifies the table that should contain the results of the query. sql="select id, title, created from blog_entry" \

If you want to save the results of a custom SQL query, do this: db-to-sqlite "postgresql://localhost/myblog" output.db \ When running -all you can specify tables to skip using -skip: db-to-sqlite "postgresql://localhost/myblog" blog.db \ For example: db-to-sqlite "postgresql://localhost/myblog" blog.db \

Any foreign key relationships will be detected and added to the SQLite database. You can also save the data from all of your tables, effectively creating a SQLite copy of your entire database. postgres-schema TEXT PostgreSQL schema to useįor 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 \ index-fks / -no-index-fks Should foreign keys have indexes? Default on pk TEXT Optional column to use as a primary key output TEXT Table in which to save -sql query results skip TEXT When using -all skip these tables tmp/my_database.dbĬONNECTION is a SQLAlchemy connection string, for PATH is a path to the SQLite file to create, e.c. Usage Usage: db-to-sqlite CONNECTION PATH

#Export a table from db browser for sqlite install
Installing the mysqlclient library on OS X can be tricky - I've found this recipe to work (run that before installing db-to-sqlite).įor PostgreSQL, use this: 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' Install from PyPI like so: pip install db-to-sqlite CLI tool for exporting tables or queries from any SQL database to a SQLite file.
