(args: Namespace)
| 32 | |
| 33 | |
| 34 | def main_sync(args: Namespace) -> None: |
| 35 | test = CopyPutTest(args) |
| 36 | with psycopg.Connection.connect(args.dsn) as conn: |
| 37 | with conn.cursor() as cur: |
| 38 | writer = getattr(psycopg.copy, args.writer)(cur) if args.writer else None |
| 39 | cur.execute(test.get_table_stmt()) |
| 40 | t0 = time() |
| 41 | with cur.copy(test.get_copy_stmt(), writer=writer) as copy: |
| 42 | for i in range(args.nrecs): |
| 43 | copy.write_row(test.get_record()) |
| 44 | tf = time() |
| 45 | |
| 46 | logger.info("time to copy: %.6f sec", tf - t0) |
| 47 | |
| 48 | |
| 49 | async def main_async(args: Namespace) -> None: |
no test coverage detected