MCPcopy
hub / github.com/psycopg/psycopg / work

Function work

tests/test_copy_async.py:854–883  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

852 faker.make_records(20)
853
854 async def work():
855 async with await aconn_cls.connect(dsn) as conn:
856 async with conn.cursor(binary=fmt) as cur:
857 await cur.execute(faker.drop_stmt)
858 await cur.execute(faker.create_stmt)
859 async with faker.find_insert_problem_async(conn):
860 await cur.executemany(faker.insert_stmt, faker.records)
861
862 stmt = sql.SQL(
863 "copy (select {} from {} order by id) to stdout (format {})"
864 ).format(
865 sql.SQL(", ").join(faker.fields_names),
866 faker.table_name,
867 sql.SQL(fmt.name),
868 )
869
870 async with cur.copy(stmt) as copy:
871 if set_types:
872 copy.set_types(faker.types_names)
873
874 if method == "read":
875 while await copy.read():
876 pass
877 elif method == "iter":
878 await alist(copy)
879 elif method == "row":
880 while (await copy.read_row()) is not None:
881 pass
882 elif method == "rows":
883 await alist(copy.rows())
884
885 gc.collect()
886 n = []

Callers 2

test_copy_to_leaksFunction · 0.70
test_copy_from_leaksFunction · 0.70

Calls 15

alistFunction · 0.85
formatMethod · 0.80
set_typesMethod · 0.80
assert_recordMethod · 0.80
connectMethod · 0.45
cursorMethod · 0.45
executeMethod · 0.45
executemanyMethod · 0.45
joinMethod · 0.45
copyMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected