def make_settings_table():
    with TRN:
        settings = AMGUT_CONFIG.get_settings()

        columns = [' '.join([setting[0], 'varchar']) for setting in settings]
        column_names = [setting[0] for setting in settings]

        num_values = len(settings)
        sql = "INSERT INTO settings ({}) VALUES ({})".format(
            ', '.join(column_names), ', '.join(['%s'] * num_values))
        args = [str(setting[1]) for setting in settings]

        create_sql = ("CREATE TABLE ag.settings ({}, current_patch varchar "
                      "NOT NULL DEFAULT 'unpatched')")

        create_sql = create_sql.format(', '.join(columns))
        TRN.add(create_sql)
        TRN.add(sql, args)
Exemple #2
0
def make_settings_table():
    with TRN:
        settings = AMGUT_CONFIG.get_settings()

        columns = [' '.join([setting[0], 'varchar']) for setting in settings]
        column_names = [setting[0] for setting in settings]

        num_values = len(settings)
        sql = "INSERT INTO settings ({}) VALUES ({})".format(
            ', '.join(column_names), ', '.join(['%s'] * num_values))
        args = [str(setting[1]) for setting in settings]

        create_sql = ("CREATE TABLE ag.settings ({}, current_patch varchar "
                      "NOT NULL DEFAULT 'unpatched')")

        create_sql = create_sql.format(', '.join(columns))
        TRN.add(create_sql)
        TRN.add(sql, args)
def make_settings_table():
    conn = SQLConnectionHandler()
    settings = AMGUT_CONFIG.get_settings()

    columns = [' '.join([setting[0], 'varchar']) for setting in settings]
    column_names = [setting[0] for setting in settings]

    num_values = len(settings)
    sql = "INSERT INTO settings ({}) VALUES ({})".format(
        ', '.join(column_names), ', '.join(['%s'] * num_values))
    args = [str(setting[1]) for setting in settings]

    with conn.get_postgres_cursor() as cur:
        create_sql = ("CREATE TABLE ag.settings ({}, current_patch varchar "
                      "NOT NULL DEFAULT 'unpatched')")

        create_sql = create_sql.format(', '.join(columns))

        cur.execute(create_sql)
        cur.execute(sql, args)