| 38 | |
| 39 | |
| 40 | async def main1(): |
| 41 | connection_string = ( |
| 42 | f"dbname='{DB}' user='{USER}' password='{PASSWORD}' host='{HOST}' port={PORT}" |
| 43 | ) |
| 44 | pool = AsyncConnectionPool(connection_string, open=False) |
| 45 | await pool.open() |
| 46 | |
| 47 | try: |
| 48 | conn = await pool.getconn(timeout=10) |
| 49 | async with conn.cursor() as curs: |
| 50 | try: |
| 51 | await curs.execute('SET search_path = ag_catalog, "$user", public') |
| 52 | await curs.execute("SELECT create_graph('dickens-2')") |
| 53 | await conn.commit() |
| 54 | print("create_graph success") |
| 55 | except ( |
| 56 | psycopg.errors.InvalidSchemaName, |
| 57 | psycopg.errors.UniqueViolation, |
| 58 | ): |
| 59 | print("create_graph already exists") |
| 60 | await conn.rollback() |
| 61 | finally: |
| 62 | pass |
| 63 | |
| 64 | |
| 65 | db = PostgreSQLDB( |