Name | sqlite-utils-move-tables JSON |
Version |
0.1
JSON |
| download |
home_page | |
Summary | Command for sqlite-utils to move tables from one database to another |
upload_time | 2023-09-01 02:10:22 |
maintainer | |
docs_url | None |
author | Simon Willison |
requires_python | |
license | Apache-2.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# sqlite-utils-move-tables
[![PyPI](https://img.shields.io/pypi/v/sqlite-utils-move-tables.svg)](https://pypi.org/project/sqlite-utils-move-tables/)
[![Changelog](https://img.shields.io/github/v/release/simonw/sqlite-utils-move-tables?include_prereleases&label=changelog)](https://github.com/simonw/sqlite-utils-move-tables/releases)
[![Tests](https://github.com/simonw/sqlite-utils-move-tables/workflows/Test/badge.svg)](https://github.com/simonw/sqlite-utils-move-tables/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/sqlite-utils-move-tables/blob/main/LICENSE)
Command for sqlite-utils to move tables from one database to another
## Installation
Install this plugin in the same environment as `sqlite-utils`.
```bash
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.
```bash
sqlite-utils move-tables origin.db destination.db tablename
```
You can pass multiple tables to the command to move multiple tables in one go:
```bash
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`:
```bash
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:
```bash
cd sqlite-utils-move-tables
python3 -m venv venv
source venv/bin/activate
```
Now install the dependencies and test dependencies:
```bash
pip install -e '.[test]'
```
To run the tests:
```bash
pytest
```
Raw data
{
"_id": null,
"home_page": "",
"name": "sqlite-utils-move-tables",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Simon Willison",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/a8/ef/91bb48cd6cc8cff227027cdd7768cbbe69cf5007d2a55f072ee01efd277d/sqlite-utils-move-tables-0.1.tar.gz",
"platform": null,
"description": "# sqlite-utils-move-tables\n\n[![PyPI](https://img.shields.io/pypi/v/sqlite-utils-move-tables.svg)](https://pypi.org/project/sqlite-utils-move-tables/)\n[![Changelog](https://img.shields.io/github/v/release/simonw/sqlite-utils-move-tables?include_prereleases&label=changelog)](https://github.com/simonw/sqlite-utils-move-tables/releases)\n[![Tests](https://github.com/simonw/sqlite-utils-move-tables/workflows/Test/badge.svg)](https://github.com/simonw/sqlite-utils-move-tables/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/sqlite-utils-move-tables/blob/main/LICENSE)\n\nCommand for sqlite-utils to move tables from one database to another\n\n## Installation\n\nInstall this plugin in the same environment as `sqlite-utils`.\n```bash\nsqlite-utils install sqlite-utils-move-tables\n```\n## Usage\n\nThis 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.\n```bash\nsqlite-utils move-tables origin.db destination.db tablename\n```\nYou can pass multiple tables to the command to move multiple tables in one go:\n```bash\nsqlite-utils move-tables origin.db destination.db table1 table2\n```\nA 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.\n\nForeign key constraints, indexes and triggers will not be copied across.\n\nTo keep the original table, use `--keep`:\n\n```bash\nsqlite-utils move-tables origin.db destination.db tablename --keep\n```\nThe 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.\n\nTo ignore that error and fail silently if a table is missing or already created, use `--ignore`.\n\nTo over-write and replace a table in the destination database with a name that matches one of the tables to be moved, use `--replace`.\n\n**It is advisable to create a copy of your origin database before running this command!**\n\n## Development\n\nTo set up this plugin locally, first checkout the code. Then create a new virtual environment:\n```bash\ncd sqlite-utils-move-tables\npython3 -m venv venv\nsource venv/bin/activate\n```\nNow install the dependencies and test dependencies:\n```bash\npip install -e '.[test]'\n```\nTo run the tests:\n```bash\npytest\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Command for sqlite-utils to move tables from one database to another",
"version": "0.1",
"project_urls": {
"CI": "https://github.com/simonw/sqlite-utils-move-tables/actions",
"Changelog": "https://github.com/simonw/sqlite-utils-move-tables/releases",
"Homepage": "https://github.com/simonw/sqlite-utils-move-tables",
"Issues": "https://github.com/simonw/sqlite-utils-move-tables/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5446c06888732393623fa1a2d9e7c84954707aaf46d2be8c962d2581efe6d598",
"md5": "4eee5949b0e7fc8cbfc4d3b337748713",
"sha256": "9bf4dd3b6d5b5a354f3e96a410336520c04012dabc05ddee437c478214088ca9"
},
"downloads": -1,
"filename": "sqlite_utils_move_tables-0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4eee5949b0e7fc8cbfc4d3b337748713",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7756,
"upload_time": "2023-09-01T02:10:21",
"upload_time_iso_8601": "2023-09-01T02:10:21.234401Z",
"url": "https://files.pythonhosted.org/packages/54/46/c06888732393623fa1a2d9e7c84954707aaf46d2be8c962d2581efe6d598/sqlite_utils_move_tables-0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a8ef91bb48cd6cc8cff227027cdd7768cbbe69cf5007d2a55f072ee01efd277d",
"md5": "52bad1cb156aae229982dab1fa17dcfb",
"sha256": "40cd90305f8bd56082961c86a91d3a6e2bc428e1b31b41d768759158695d79df"
},
"downloads": -1,
"filename": "sqlite-utils-move-tables-0.1.tar.gz",
"has_sig": false,
"md5_digest": "52bad1cb156aae229982dab1fa17dcfb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7872,
"upload_time": "2023-09-01T02:10:22",
"upload_time_iso_8601": "2023-09-01T02:10:22.890181Z",
"url": "https://files.pythonhosted.org/packages/a8/ef/91bb48cd6cc8cff227027cdd7768cbbe69cf5007d2a55f072ee01efd277d/sqlite-utils-move-tables-0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-01 02:10:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "simonw",
"github_project": "sqlite-utils-move-tables",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "sqlite-utils-move-tables"
}