Beispiel #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()
Beispiel #2
0
 def cursor(self, *args, **kwargs):
     kwargs.setdefault('cursor_factory', MyLoggingCursor)
     return LoggingConnection.cursor(self, *args, **kwargs)
Beispiel #3
0
"""
from psycopg2.extras import LoggingConnection

if __name__ == '__main__':
    import sys

    dsn = "host='{}' user='******' password='******' dbname={}".format(
        os.environ['OLD_USERS_DB_HOST'], os.environ['OLD_USERS_DB_USER'],
        os.environ['OLD_USERS_DB_PASSWORD'], os.environ['OLD_USERS_DB_NAME'])
    conn = psycopg2.connect(dsn)
    logfile = open('/tmp/db.log', 'a')
    conn = LoggingConnection(dsn)
    conn.initialize(logfile)

    cur = conn.cursor()
    try:
        dsn2 = "host='{}' user='******' password='******' dbname={}".format(
            os.environ['USERS_DB_HOST'], os.environ['USERS_DB_USER'],
            os.environ['USERS_DB_PASSWORD'], os.environ['USERS_DB_NAME'])
        conn2 = psycopg2.connect(dsn2)
        logfile2 = open('/tmp/db_new.log', 'a')
        conn2 = LoggingConnection(dsn2)
        conn2.initialize(logfile2)
        cur2 = conn2.cursor(cursor_factory=DictCursor)
        try:
            fecha = None
            ''' sinc usuarios '''
            cur2.execute('select max(fecha) from scripts')
            if cur2.rowcount > 0:
                data = cur2.fetchone()
Beispiel #4
0
import pandas as pd
import os
import urllib
import shutil

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
hdlr = logging.FileHandler('import_errors.log')
logger.addHandler(hdlr)
logger.info("getting started")

# Set up DB connection
conn_string = os.environ.get('DATABASE_URL') or "dbname=bactdbtest user=matthew"
conn = LoggingConnection(conn_string)
LoggingConnection.initialize(conn, logger)
c = conn.cursor()

dt = datetime.datetime.now()
logger.info(dt)
text_measurements = [
    ("+", dt, dt),
    ("-", dt, dt),
    ("(+)", dt, dt),
    ("(-)", dt, dt),
    ("+/-", dt, dt),
    ("-/+", dt, dt),
    ("TD", dt, dt),
    ("NR", dt, dt),
    ("S", dt, dt),
    ("I", dt, dt),
    ("R", dt, dt),
Beispiel #5
0
 def cursor(self, *args, **kwargs):
     kwargs.setdefault('cursor_factory', PerfLoggingCursor)
     return LoggingConnection.cursor(self, *args, **kwargs)