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

Function work

tests/test_copy.py:835–864  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

833 faker.make_records(20)
834
835 def work():
836 with conn_cls.connect(dsn) as conn:
837 with conn.cursor(binary=fmt) as cur:
838 cur.execute(faker.drop_stmt)
839 cur.execute(faker.create_stmt)
840 with faker.find_insert_problem(conn):
841 cur.executemany(faker.insert_stmt, faker.records)
842
843 stmt = sql.SQL(
844 "copy (select {} from {} order by id) to stdout (format {})"
845 ).format(
846 sql.SQL(", ").join(faker.fields_names),
847 faker.table_name,
848 sql.SQL(fmt.name),
849 )
850
851 with cur.copy(stmt) as copy:
852 if set_types:
853 copy.set_types(faker.types_names)
854
855 if method == "read":
856 while copy.read():
857 pass
858 elif method == "iter":
859 list(copy)
860 elif method == "row":
861 while copy.read_row() is not None:
862 pass
863 elif method == "rows":
864 list(copy.rows())
865
866 gc.collect()
867 n = []

Callers 2

test_copy_to_leaksFunction · 0.70
test_copy_from_leaksFunction · 0.70

Calls 15

find_insert_problemMethod · 0.80
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
read_rowMethod · 0.45

Tested by

no test coverage detected