|
@@ -11,35 +11,35 @@ redis_info = config_.REDIS_INFO
|
|
# R = get_redis_connect()
|
|
# R = get_redis_connect()
|
|
|
|
|
|
pg_info = config_.HOLOGRES_INFO
|
|
pg_info = config_.HOLOGRES_INFO
|
|
-# P = aiopg.connect(database=pg_info['dbname'],
|
|
|
|
-# user=pg_info['user'],
|
|
|
|
-# password=pg_info['password'],
|
|
|
|
-# host=pg_info['host'])
|
|
|
|
|
|
+P = aiopg.connect(database=pg_info['dbname'],
|
|
|
|
+ user=pg_info['user'],
|
|
|
|
+ password=pg_info['password'],
|
|
|
|
+ host=pg_info['host'],
|
|
|
|
+ port=pg_info['port'])
|
|
|
|
|
|
|
|
|
|
R = aioredis.from_url(redis_info['host'], password=redis_info['password'])
|
|
R = aioredis.from_url(redis_info['host'], password=redis_info['password'])
|
|
# async def get_redis_connect():
|
|
# async def get_redis_connect():
|
|
# return await aioredis.from_url(redis_info['host'], password=redis_info['password'])
|
|
# return await aioredis.from_url(redis_info['host'], password=redis_info['password'])
|
|
|
|
|
|
-# async def pg_getdata(sql):
|
|
|
|
-# P = await aiopg.connect(database=pg_info['dbname'],
|
|
|
|
-# user=pg_info['user'],
|
|
|
|
-# password=pg_info['password'],
|
|
|
|
-# host=pg_info['host'],
|
|
|
|
-# port=pg_info['port'])
|
|
|
|
-# cur = await P.cursor()
|
|
|
|
-# await cur.execute(sql)
|
|
|
|
-# ret = await cur.fetchall()
|
|
|
|
-# return ret
|
|
|
|
-
|
|
|
|
-dsn = f'dbname={pg_info["dbname"]} user={pg_info["user"]} password={pg_info["password"]} host={pg_info["host"]} port={pg_info["port"]}'
|
|
|
|
-print(dsn)
|
|
|
|
async def pg_getdata(sql):
|
|
async def pg_getdata(sql):
|
|
- pool = await aiopg.create_pool(dsn)
|
|
|
|
- async with pool.acquire() as conn:
|
|
|
|
- async with conn.cursor() as cur:
|
|
|
|
- await cur.execute(sql)
|
|
|
|
- return await cur.fetchall()
|
|
|
|
|
|
+ P = await aiopg.connect(database=pg_info['dbname'],
|
|
|
|
+ user=pg_info['user'],
|
|
|
|
+ password=pg_info['password'],
|
|
|
|
+ host=pg_info['host'],
|
|
|
|
+ port=pg_info['port'])
|
|
|
|
+ cur = await P.cursor()
|
|
|
|
+ await cur.execute(sql)
|
|
|
|
+ ret = await cur.fetchall()
|
|
|
|
+ return ret
|
|
|
|
+
|
|
|
|
+# dsn = f'dbname={pg_info["dbname"]} user={pg_info["user"]} password={pg_info["password"]} host={pg_info["host"]} port={pg_info["port"]}'
|
|
|
|
+# async def pg_getdata(sql):
|
|
|
|
+# pool = await aiopg.create_pool(dsn)
|
|
|
|
+# async with pool.acquire() as conn:
|
|
|
|
+# async with conn.cursor() as cur:
|
|
|
|
+# await cur.execute(sql)
|
|
|
|
+# return await cur.fetchall()
|
|
|
|
|
|
async def key_exists(key_name):
|
|
async def key_exists(key_name):
|
|
"""
|
|
"""
|
|
@@ -173,9 +173,9 @@ async def add_data_with_set(key_name, values, expire_time=30*60):
|
|
:param expire_time: 过期时间,单位:s,默认0.5小时
|
|
:param expire_time: 过期时间,单位:s,默认0.5小时
|
|
:return: None
|
|
:return: None
|
|
"""
|
|
"""
|
|
- R.sadd(key_name, *values)
|
|
|
|
|
|
+ await R.sadd(key_name, *values)
|
|
# 设置过期时间
|
|
# 设置过期时间
|
|
- R.expire(key_name, expire_time)
|
|
|
|
|
|
+ await R.expire(key_name, expire_time)
|
|
|
|
|
|
async def data_exists_with_set(key_name, value):
|
|
async def data_exists_with_set(key_name, value):
|
|
"""
|
|
"""
|