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

Function work

tests/crdb/test_copy_async.py:209–230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

207 faker.make_records(20)
208
209 async def work():
210 async with await aconn_cls.connect(dsn) as conn:
211 async with conn.cursor(binary=fmt) as cur:
212 await cur.execute(faker.drop_stmt)
213 await cur.execute(faker.create_stmt)
214
215 stmt = sql.SQL("copy {} ({}) from stdin {}").format(
216 faker.table_name,
217 sql.SQL(", ").join(faker.fields_names),
218 sql.SQL("with binary" if fmt else ""),
219 )
220 async with cur.copy(stmt) as copy:
221 if set_types:
222 copy.set_types(faker.types_names)
223 for row in faker.records:
224 await copy.write_row(row)
225
226 await cur.execute(faker.select_stmt)
227 recs = await cur.fetchall()
228
229 for got, want in zip(recs, faker.records):
230 faker.assert_record(got, want)
231
232 gc.collect()
233 n = []

Callers 1

test_copy_from_leaksFunction · 0.70

Calls 10

formatMethod · 0.80
set_typesMethod · 0.80
assert_recordMethod · 0.80
connectMethod · 0.45
cursorMethod · 0.45
executeMethod · 0.45
joinMethod · 0.45
copyMethod · 0.45
write_rowMethod · 0.45
fetchallMethod · 0.45

Tested by

no test coverage detected