Coder Social home page Coder Social logo

sqlite-utils-move-tables's Introduction

sqlite-utils-move-tables

PyPI Changelog Tests License

Command for sqlite-utils to move tables from one database to another

Installation

Install this plugin in the same environment as sqlite-utils.

sqlite-utils install sqlite-utils-move-tables

Usage

This plugin adds a single command, sqlite-utils move-tables. The command can be used to move one or more tables from one database file to another.

sqlite-utils move-tables origin.db destination.db tablename

You can pass multiple tables to the command to move multiple tables in one go:

sqlite-utils move-tables origin.db destination.db table1 table2

A moved table will have its columns and primary keys recreated and all data copied across to the new database. The original table will then be dropped.

Foreign key constraints, indexes and triggers will not be copied across.

To keep the original table, use --keep:

sqlite-utils move-tables origin.db destination.db tablename --keep

The command checks for the existence of all of the tables in the first database, and ensures they do not yet exist in the second database. It will show an error if either of these conditions are not meant.

To ignore that error and fail silently if a table is missing or already created, use --ignore.

To over-write and replace a table in the destination database with a name that matches one of the tables to be moved, use --replace.

It is advisable to create a copy of your origin database before running this command!

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd sqlite-utils-move-tables
python3 -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

sqlite-utils-move-tables's People

Contributors

simonw avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

sqlite-utils-move-tables's Issues

Initial plugin design

This is going to add a move-tables command:

sqlite-utils move-tables origin.db destination.db table1 table2 table3

This will move the tables in question from origin to destination, making sure they are safely committed in destination before it drops the from origin.

Options:

  • --keep - don't drop the tables from origin.db
  • --ignore - ignore any tables that are missing from origin.db or have been moved already
  • --replace - over-write tables in destination if necessary

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.