コード例 #1
0
def create_call_trace_table(connection: LoggingConnection):
    with connection.cursor() as cursor:
        query = """
CREATE TABLE IF NOT EXISTS {func_table} (
    id          SERIAL PRIMARY KEY ,
    module      TEXT,
    qualname    TEXT,
    arg_types   JSONB,
    return_type JSONB,
    yield_type  JSONB
);

CREATE TABLE IF NOT EXISTS {class_table} (
    id SERIAL PRIMARY KEY ,
    module TEXT,
    qualname TEXT,
    props JSONB
)
""".format(func_table=FUNCTION_CALLS_TABLE, class_table=CLASS_PROPERTIES_TABLE)

        cursor.execute(query)
    connection.commit()
コード例 #2
0
                cur.execute(
                    'update profile.users set dni=%(dni)s, name=%(name)s, lastname=%(lastname)s, sincronizado_1=NOW() where id=%(id)s',
                    u)
                if cur.rowcount <= 0:
                    cur.execute(
                        'insert into profile.users (id,dni,name,lastname,sincronizado_1) values (%(id)s, %(dni)s, %(name)s, %(lastname)s, NOW())',
                        u)
                cur.execute(
                    'update students.users set student_number=%(legajo)s where id=%(id)s',
                    u)
                if cur.rowcount <= 0:
                    cur.execute(
                        'insert into students.users (id,student_number) values (%(id)s, %(legajo)s)',
                        u)

            conn.commit()
            ''' sinc claves '''
            cur2.execute(
                'select id, user_id, username, password, creado, actualizado from user_password where actualizado > %s or creado > %s',
                (fecha, fecha))
            for u in cur2.fetchall():
                logging.debug('actualizando clave : {}'.format(u))
                #sys.stdout.write('.')
                #sys.stdout.flush()
                cur.execute(
                    'update credentials.user_password set password = %(password)s, sincronizado_1=NOW() where user_id = %(user_id)s',
                    u)
                if cur.rowcount <= 0:
                    cur.execute(
                        'insert into credentials.user_password (id, user_id, username, password, sincronizado_1) values (%(id)s, %(user_id)s, %(username)s, %(password)s, NOW())',
                        u)