Skip to main content

Database schema migration tool that works in SQL

Project description

Overview

This tool helps you to keep track and evolve your database schema (SQL).

It works like this. Whenever you make changes to the database schema you put them into a “migration” - simply an .sql file with a sequence of SQL statements. Sqlturk keeps track of which migrations have been applied and runs them in a guaranteed order.

Design

There are plenty of tools to approach the problem of database schema migration. Here is how sqlturk is different:

  • one-way migrations. There is no way to “rollback” a migration. In my experience, “downgrade” scripts are almost never used yet writing them adds considerable burden onto the developer. Their presense may add a false sense of security – since they used so rarely there is a big chance they will not work properly anyway.

  • Python-agnostic. Sqlturk operates in terms of SQL DDL. It does not work in terms of SQLAlchemy ORM models or Django’s and thus it can be used in a much wider context. Plain SQL also means that a competent DBA who knows nothing about Python can author these scripts. Or they could be generated automatically by another tool.

  • no magic. I wanted a tool that works in an obvious, easy-to-understand way. Changing database schema can have big consequences so it is important to be able to see what’s going on.

Not convinced? A couple of more sophisticated tools: Django South and sqlalchemy-migrate.

API usage

Short example:

>>> from sqlturk.migration import MigrationTool
>>> tool = MigrationTool('sqlite:///:memory:', migration_dir='testmigrations')
>>> tool.install() # create a database table to track schema changes
>>> tool.find_migrations()
['1_foobar', '2_foobar_data', '10_foobar_delete']
>>> tool.run_migrations()
>>> tool.find_migrations() # check that all migrations have been applied
[]

Example migration scripts can be found in the sqlturk’ source. Sqlturk uses SQLAlchemy syntax to specify database connection string, see its documentation for details.

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

sqlturk-0.9.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distributions

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

sqlturk-0.9.1-py2.6.egg (8.1 kB view details)

Uploaded Egg

sqlturk-0.9.1-py2.5.egg (7.7 kB view details)

Uploaded Egg

File details

Details for the file sqlturk-0.9.1.tar.gz.

File metadata

  • Download URL: sqlturk-0.9.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sqlturk-0.9.1.tar.gz
Algorithm Hash digest
SHA256 a9db43e5557689cdad45db9bcfcf182dfea8d867c3312f75559161b44ac534c4
MD5 df704b801fbb9086ae7e0a25aed630de
BLAKE2b-256 3b18818ebd8a6f288deaafded4edaf8698de195bee07887fdc0b55726d1b75fc

See more details on using hashes here.

File details

Details for the file sqlturk-0.9.1-py2.6.egg.

File metadata

  • Download URL: sqlturk-0.9.1-py2.6.egg
  • Upload date:
  • Size: 8.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sqlturk-0.9.1-py2.6.egg
Algorithm Hash digest
SHA256 4636354e4d3faf58e5bcc974b154f29973a6b998de1b331415b81303c3f2b3e2
MD5 1e3266b38399acbb3cd28a8b9a84f70f
BLAKE2b-256 da44b943356b47b1e374a6e6110100b1a9a00162d755dbe1cd9da6aa7989bbe6

See more details on using hashes here.

File details

Details for the file sqlturk-0.9.1-py2.5.egg.

File metadata

  • Download URL: sqlturk-0.9.1-py2.5.egg
  • Upload date:
  • Size: 7.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sqlturk-0.9.1-py2.5.egg
Algorithm Hash digest
SHA256 9d2c71a3247d927fc21b41f783420e50580098afef5f151699169d4b89c4905f
MD5 9a3d45da4908ea792c18a657c8a5cf66
BLAKE2b-256 f7afa0de73c15d41fff15864b3c63922634edcc698152f07eec783aecaaacfc0

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