def create_database(cfg, default_traits): dsn = cfg.get_dsn() dsn['dbname'] = 'mishmash' conn = QuickConn(dsn) cmd = StatementCursor(conn, 'create_database') for table in cmd.tables(): cmd.execute('drop table %s' %table) start_schema(conn, default_traits) make_suites(conn) cmd.execute(grant_public(cmd.tables())) cmd.execute(grant_public(['current_environment'], 'ALL'))
def create_database(cfg, default_traits): dsn = cfg.get_dsn() dsn['dbname'] = 'mishmash' conn = QuickConn(dsn) cmd = StatementCursor(conn, 'create_database') for table in cmd.tables(): cmd.execute('drop table %s' % table) start_schema(conn, default_traits) make_suites(conn) cmd.execute(grant_public(cmd.tables())) cmd.execute(grant_public(['current_environment'], 'ALL'))
def start_schema(conn): cursor = StatementCursor(conn, 'start_schema') tables, mapping = primary_tables() map(cursor.create_table, tables) priorities_table = mapping['priorities'] insert_list(cursor, priorities_table.name, 'priority', PRIORITIES) insert_list(cursor, 'scriptnames', 'script', SCRIPTS) cursor.execute(grant_public([x.name for x in tables])) cursor.execute(grant_public(['current_environment'], 'ALL')) cursor.execute(grant_public(['partition_workspace'], 'ALL')) cursor.execute(plpgsql_delete_profile) cursor.execute(plpgsql_delete_trait)
def make_suite(cursor, suite): tables = suite_tables(suite) map(cursor.create_table, tables) cursor.execute(grant_public([x.name for x in tables]))