by BiteCode_dev · 5y ago · 0 comments
async def main():
db = DB()
await db.connect('db_name', {
'host': 'localhost',
'port': '5432',
'database': 'db_name',
'username': 'db_user_name',
'password': 'db_user_password'
}, default=True)
await db.connect('other_db_name', {
'host': 'localhost',
'port': '5432',
'database': 'other_db_name',
'username': 'db_user_name',
'password': 'db_user_password'
}, default=False)
db.connection('other_db_name')
db.default = 'other_db_name'
await db.stop()
asyncio.run(main())
Am I missing something ? It's using asyncio.run() in other examples, so it assumes 3.7+ anyway.The asyncio.run() is just to pretend I run the lib snippet in a code that already started the loop, which the doc seems to do.