Skip to main content

Command-line tool to simplify some common maintenance tasks on PostgreSQL databases

Project description

https://badge.fury.io/py/pgtool.svg Travis CI

PGtool is a command-line tool designed to simplify some common maintenance tasks on PostgreSQL databases. It works with Python 2.7 and 3.3+ using the psycopg2 driver.

Available commands:

cp SOURCE DEST

Uses CREATE DATABASE … TEMPLATE to create a duplicate of a database. Additionally copies over database-specific settings.

When used with –force, an existing database with the same name as DEST is replaced, the original is renamed out of place in the form DEST_old_YYYYMMDD (unless –no-backup is specified).

mv SOURCE DEST

Rename a database within a server.

When used with –force, an existing database with the same name as DEST is replaced, the original is renamed out of place in the form DEST_old_YYYYMMDD (unless –no-backup is specified).

kill DBNAME [DBNAME …]

Kills all active connections to the specified database(s).

reindex IDXNAME [IDXNAME …]

Uses CREATE INDEX CONCURRENTLY to create a duplicate index, then tries to swap the new index for the original.

The index swap is done using a short lock timeout to prevent it from interfering with running queries. Retries until the rename succeeds.

Resources

Changelog

0.0.1 (2015-10-26)

  • Initial public release, commands: ‘cp’, ‘mv’, ‘kill’ & ‘reindex’

Contributing

Code style:

  • In general follow the Python PEP-8 coding style, except line length can go up to 120 chars.

  • Strings that have meaning for humans use double quotes ("), otherwise single quotes ('). When in doubt, don’t worry about it.

  • Code should be compatible with both Python 2 and 3, preferably without version-specific conditionals.

Run the test suite using python setup.py test.

Submit your changes as pull requests on GitHub.

License

Copyright 2015 Voicecom, Marti Raudsepp & contributors

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pgtool-0.0.1.tar.gz (7.6 kB view details)

Uploaded Source

File details

Details for the file pgtool-0.0.1.tar.gz.

File metadata

  • Download URL: pgtool-0.0.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pgtool-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f6f0c8716b95634e1d0a2e5bf48de5e5aea68b1b0d8ac66ea0a6e1b6d28fb925
MD5 eac704a8cfb4f21ec079a16d6f894aca
BLAKE2b-256 4823410c484407fee9dc1101481e3c185188c28846fa724c8629f1b88f1be0ad

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page