Skip to main content

No project description provided

Project description

Redscope

Redscope is a database migration and introspection tool, designed to help manage your instance of Amazon Redshift. All migrations are written in plain SQL, in .sql files, with no fancy tricks or dependencies on ORM frameworks.

Migration files are timestamp tracked, to eliminate the possibility of a migration key duplication.

Getting Started

Install

Redscope can be installed by using pip.

pip install redscope

New Project

Once Redscope is installed, create a new project.

redscope init project

This will create the directories where your migrations, ddl, and log files will live. The redscope.log file is used to record every command executed in redscope.

database
    ddl
    logs
        redscope.log
    migrations

Environments

By default, Redscope will look for a .env file in the root directory of your project, and will load the connection string in REDSCOPE_DB_URL as an environment variable.

Init Database

Once a connection string has been provided in a .env file, the tables to keep track of applied migrations must be created. Running the below command will create a schema and table redscope.migrations.

redscope init db

Creating Migrations

To create a new migration run the below command, where name-of-my-migration is the name you want for your migration. This will create a directory in the migrations directory which will contain 2 files up.sql and down.sql

redscope new migration --name name-of-my-migration

In up.sql, place the SQL commands you want to execute against the database to bring the data base up to the newest state. In down.sql, place the SQL commands to run, to undo the changes made to the database when the up.sql file was executed.

Running Migrations

To execute all un-applied migrations

redscope migrate up

This will apply all the local migration files, against the target database.

To revert the changes

redscope migrate down

Custom Environments

In larger projects, perhaps it is possible to have several .env files and connections to databases which code in your cool project uses to perform some database operation. redscope allows using custom .env files, and custom environment variables. Redscope will however expect that this file lives in the root directory of your project.

To load a custom .env file, but use the default REDSCOPE_DB_URL pass the optional --env-file parameter.

redscope migrate up --env-file dev.env

To load the default .env file, however use a custom environment variable

redscope migrate up --env-var MY_OTHER_DB_CONN_STRING

To load both a custom file, and custom var

redscope migrate up --env-file dev.env --env-var MY_OTHER_DB_CONN_STRING

This makes it possible to connect redscope to several databases in a single project.

To load a custom environment, eg my_cool_file.env simply pass the file name

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

redscope-0.2.9.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

redscope-0.2.9-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file redscope-0.2.9.tar.gz.

File metadata

  • Download URL: redscope-0.2.9.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.10

File hashes

Hashes for redscope-0.2.9.tar.gz
Algorithm Hash digest
SHA256 e66e25f807a10225b90fb6b90082e0d8bf37b9d01270ad2c0b627f57869989ad
MD5 4508aaeb44a3f91084873cde5b11102a
BLAKE2b-256 ce02a1e5458acf576ef9bec8c7d7ff7b93ceda54e5757ae82b9f594a3492dc02

See more details on using hashes here.

File details

Details for the file redscope-0.2.9-py3-none-any.whl.

File metadata

  • Download URL: redscope-0.2.9-py3-none-any.whl
  • Upload date:
  • Size: 31.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.10

File hashes

Hashes for redscope-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 88d712c58dfcd024970f3546eabe54b4389ae3a426622d38bf7f70f132a8e86d
MD5 a92d20a53599ce221441d13657ff8d71
BLAKE2b-256 d0c2a64be7ac2fccbb73fa76d61d59cd1dabf494a7e9fdc433488447bc9448c7

See more details on using hashes here.

Supported by

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