watson.db.commands

class watson.db.commands.Database(config)[source]

Database commands.

_session_or_engine(type_)[source]

Retrieves all the sessions or engines from the container.

create(drop)[source]

Create the relevant databases.

dump()[source]

Print the Schema of the database.

generate_fixtures(models, output_to_stdout)[source]

Generate fixture data in json format.

Parameters:
  • models (string) – A comma separated list of models to output
  • output_to_stdout (boolean) – Whether or not to output to the stdout
generate_models(connection_string=None, tables=None, outfile=None)[source]

Generate models from an existing database schema.

Parameters:
  • connection_string (string) – The database to connect to
  • tables (string) – Tables to process (comma-separated, default: all)
  • outfile (string) – File to write output to (default: stdout)
populate()[source]

Add data from fixtures to the database(s).

class watson.db.commands.Migrate(config)[source]

Alembic integration with Watson.

branches()[source]

Show current un-spliced branch points.

current()[source]

Display the current revision for each database.

downgrade(sql=False, tag=None, revision='-1')[source]

Revert to a previous version.

history(rev_range)[source]

List changeset scripts in chronological order.

Parameters:rev_range – Revision range in format [start]:[end]
init()[source]

Initializes Alembic migrations for the project.

revision(sql=False, autogenerate=False, message=None)[source]

Create a new revision file.

Parameters:
  • sql (bool) – Don’t emit SQL to database - dump to standard output instead
  • autogenerate (bool) – Populate revision script with andidate migration operatons, based on comparison of database to model
  • message (string) – Message string to use with ‘revision’
stamp(sql=False, tag=None, revision='head')[source]

‘stamp’ the revision table with the given revision; don’t run any migrations.

Parameters:
  • sql (bool) – Don’t emit SQL to database - dump to standard output instead
  • tag (string) – Arbitrary ‘tag’ name - can be used by custom env.py scripts
  • revision (string) – Revision identifier
upgrade(sql=False, tag=None, revision='head')[source]

Upgrade to a later version.

Parameters:
  • sql (bool) – Don’t emit SQL to database - dump to standard output instead
  • tag (string) – Arbitrary ‘tag’ name - can be used by custom env.py scripts
  • revision (string) – Revision identifier