sqlobject.manager.command module

class sqlobject.manager.command.Command(invoked_as, command_name, args, runner)[source]

Bases: object

aliases = ()
ask(prompt, safe=False, default=True)[source]
classes(require_connection=True, require_some=False)[source]
classes_from_egg(egg_spec)[source]
classes_from_module(module)[source]
classes_from_package(package_name)[source]
command()[source]
config()[source]
config_from_egg(egg_spec, warn_no_sqlobject=True)[source]
connection()[source]
description = None
help = ''
ini_config(conf_fn)[source]
load_options_from_egg(egg_spec)[source]
max_args = 0
max_args_error = 'You must provide no more than %(max_args)s arguments'
min_args = 0
min_args_error = 'You must provide at least %(min_args)s arguments'
open_editor(pretext, breaker=None, extension='.txt')[source]

Open an editor with the given text. Return the new text, or None if no edits were made. If given, everything after breaker will be ignored.

orderClassesByDependencyLevel(classes)[source]

Return classes ordered by their depth in the class dependency tree (this is not the inheritance tree), from the top level (independant) classes to the deepest level. The dependency tree is defined by the foreign key relations.

prog_name
required_args = []
run()[source]
shorten_filename(fn)[source]

Shortens a filename to make it relative to the current directory (if it can). For display purposes.

class sqlobject.manager.command.CommandCreate(invoked_as, command_name, args, runner)[source]

Bases: sqlobject.manager.command.Command

command()[source]
name = 'create'
parser = <optparse.OptionParser instance>
summary = 'Create tables'
class sqlobject.manager.command.CommandDrop(invoked_as, command_name, args, runner)[source]

Bases: sqlobject.manager.command.Command

command()[source]
name = 'drop'
parser = <optparse.OptionParser instance>
summary = 'Drop tables'
class sqlobject.manager.command.CommandExecute(invoked_as, command_name, args, runner)[source]

Bases: sqlobject.manager.command.Command

command()[source]
execute_sql(sql)[source]
help = 'Runs SQL statements directly in the database, with no intervention. Useful when used with a configuration file. Each argument is executed as an individual statement.'
max_args = None
name = 'execute'
parser = <optparse.OptionParser instance>
summary = 'Execute SQL statements'
class sqlobject.manager.command.CommandHelp(invoked_as, command_name, args, runner)[source]

Bases: sqlobject.manager.command.Command

command()[source]
max_args = 1
name = 'help'
parser = <optparse.OptionParser instance>
summary = 'Show help'
class sqlobject.manager.command.CommandList(invoked_as, command_name, args, runner)[source]

Bases: sqlobject.manager.command.Command

command()[source]
name = 'list'
parser = <optparse.OptionParser instance>
summary = 'Show all SQLObject classes found'
class sqlobject.manager.command.CommandRecord(invoked_as, command_name, args, runner)[source]

Bases: sqlobject.manager.command.Command

base_dir()[source]
command()[source]
command_force_db_version()[source]
find_last_version()[source]
find_output_dir()[source]
help = 'Record state of table definitions. The state of each table is written out to a separate file in a directory, and that directory forms a "version". A table is also added to your database (sqlobject_db_version) that reflects the version the database is currently at. Use the upgrade command to sync databases with code.'
name = 'record'
parser = <optparse.OptionParser instance>
strip_comments(sql)[source]
summary = 'Record historical information about the database status'
update_db(version, conn)[source]
version_regex = <_sre.SRE_Pattern object>
class sqlobject.manager.command.CommandRunner[source]

Bases: object

invalid(msg, code=2)[source]
register(command)[source]
run(argv)[source]
class sqlobject.manager.command.CommandSQL(invoked_as, command_name, args, runner)[source]

Bases: sqlobject.manager.command.Command

command()[source]
name = 'sql'
parser = <optparse.OptionParser instance>
summary = 'Show SQL CREATE statements'
class sqlobject.manager.command.CommandStatus(invoked_as, command_name, args, runner)[source]

Bases: sqlobject.manager.command.Command

command()[source]
help = 'This command checks the SQLObject definition and checks if the tables in the database match. It can always test for missing tables, and on some databases can test for the existance of other tables. Column types are not currently checked.'
name = 'status'
parser = <optparse.OptionParser instance>
print_class(soClass)[source]
summary = 'Show status of classes vs. database'
class sqlobject.manager.command.CommandUpgrade(invoked_as, command_name, args, runner)[source]

Bases: sqlobject.manager.command.CommandRecord

best_upgrade(current, dest, target_dbname)[source]
command()[source]
current_version()[source]
help = 'This command runs scripts (that you write by hand) to upgrade a database. The database\'s current version is in the sqlobject_version table (use record --force-db-version if a database does not have a sqlobject_version table), and upgrade scripts are in the version directory you are upgrading FROM, named upgrade_DBNAME_VERSION.sql, like "upgrade_mysql_2004-12-01b.sql".'
make_plan(current, dest)[source]
name = 'upgrade'
parser = <optparse.OptionParser instance>
summary = 'Update the database to a new version (as created by record)'
upgrade_regex = <_sre.SRE_Pattern object>
class sqlobject.manager.command.SQLObjectVersionTable(**kw)[source]

Bases: sqlobject.main.SQLObject

This table is used to store information about the database and its version (used with record and update commands).

j = sqlobject_db_version
q = sqlobject_db_version
class sqlmeta(instance)

Bases: sqlobject.main.sqlmeta

childName = None
columnDefinitions = {'updated': <DateTimeCol b40942ccL updated>, 'version': <StringCol b419876cL version>}
columnList = [<SOStringCol version>, <SODateTimeCol updated default=datetime.datetime(2017, 8, 5, 19, 47, 2, 116838)>]
columns = {'updated': <SODateTimeCol updated default=datetime.datetime(2017, 8, 5, 19, 47, 2, 117180)>, 'version': <SOStringCol version>}
idName = 'id'
indexDefinitions = []
indexes = []
joinDefinitions = []
joins = []
soClass

alias of SQLObjectVersionTable

style = <sqlobject.styles.MixedCaseUnderscoreStyle object>
table = 'sqlobject_db_version'
updated
version
sqlobject.manager.command.db_differences(soClass, conn)[source]

Returns the differences between a class and the table in a connection. Returns [] if no differences are found. This function does the best it can; it can miss many differences.

sqlobject.manager.command.nowarning_tempnam(*args, **kw)[source]
sqlobject.manager.command.standard_parser(connection=True, simulate=True, interactive=False, find_modules=True)[source]
sqlobject.manager.command.update_sys_path(paths, verbose)[source]