loop = asyncio.new_event_loop() loop.set_exception_handler(default_exception_handler) params = { "user": "******", "password": "******", "host": "127.0.0.1", "port": "5432", "database": "navigator_dev", "DEBUG": True, } pool = AsyncPool('pg', loop=loop, params=params) loop.run_until_complete(pool.connect()) db = loop.run_until_complete(pool.acquire()) print('Pool Connected: ', pool.is_connected()) db = loop.run_until_complete(pool.acquire()) print('Is Connected: ', db.is_connected()) loop.run_until_complete(db.test_connection()) try: print('CREATION of MODEL::') mdl = QueryUtil(**{"query_slug": "walmart_stores"}) mdl.Meta.set_connection(db) result = loop.run_until_complete(mdl.fetch(raw_query=False)) print('RESULT IS: ', result) mdl = QueryUtil(**{"program_slug": "walmart", "provider": "db"})
# client = aredis.StrictRedis( # connection_pool=pool # ) # print(isinstance(client, aredis.StrictRedis)) # #print(loop.run_until_complete(client.info())) # loop.run_until_complete(client.execute_command("set", "Test1", "UltraTest")) # conn = client.connection_pool._available_connections[0] # conn1 = pool._available_connections[0] # assert conn == conn1 # finally: # pool.disconnect() # loop.close() rd = AsyncPool("asyncredis", dsn=redis_url, loop=loop) # # rd = redisPool(dsn=redis_url, loop=loop) loop.run_until_complete(rd.connect()) # # # rd = AsyncDB('redis', dsn=redis_url, loop=loop) # # loop.run_until_complete(rd.connection()) # # async def test_redis(pool): async with pool as db: print("Connected: {}".format(db.is_connected())) await db.test_connection() async with await pool.acquire() as conn: print(await conn.test_connection('TEST', 'TEST1')) await conn.execute("set", "Test1", "UltraTest") await conn.execute("set", "my-key", "UltraKey")