Esempio n. 1
0
async def close_connection(state):
    if state.pool:
        logger.debug('Closing asyncpg pooled connections')
        await state.pool.close()
    elif state.connection:
        logger.debug('Closing asyncpg connection')
        await state.connection.close()
Esempio n. 2
0
 async def job(state):
     logger.debug('asyncpg single connect initiating')
     s_settings = {'application_name': state.store['app_name']}
     state.connection = await asyncpg.connect(server_settings=s_settings,
                                              **state.store['setup'])
     for ext in state.store.get('extensions', []):
         await Extensions.apply(ext, state.connection)
     state.store['temp_exec'] = False
     yield state
Esempio n. 3
0
 async def apply(name, connection):
     logger.debug('Extension "%s" enabled', name)
     if name == 'json':
         await Extensions.json(connection)
     if name == 'json_out':
         await Extensions.json_out(connection)
     if name == 'dec2float':
         await Extensions.dec2float(connection)
     if name == 'str2dt':
         await Extensions.str2dt(connection)
     if name == 'str2str':
         await Extensions.str2str(connection)
Esempio n. 4
0
    async def job(state):
        logger.debug('asyncpg connection pool initiating')

        async def con_setup(connection):
            for ext in state.store.get('extensions', []):
                await Extensions.apply(ext, connection)

        s_settings = {'application_name': state.store['app_name']}
        state.pool = await asyncpg.create_pool(server_settings=s_settings,
                                               init=con_setup,
                                               **state.store['setup'])
        state.store['temp_exec'] = False
        yield state
Esempio n. 5
0
async def _prepare(state):
    if state.query is not None:
        state.prepared = await state.connection.prepare(state.query)
        state.store['prepared_query'] = state.query
        logger.debug('Storing prepared query %s', state.query)
        state.query = None
Esempio n. 6
0
 async def job(state):
     logger.debug('asyncpg acquiring connection')
     state.connection = await state.pool.acquire()
     yield state
Esempio n. 7
0
async def close_connection(state):
    if state.connection:
        logger.debug('Closing psycopg2 connection')
        state.connection.close()
Esempio n. 8
0
 def apply(name, state):
     logger.debug('Extension "%s" enabled', name)
     if name == 'dec2float':
         Extensions.dec2float(state)