MCPcopy
hub / github.com/psycopg/psycopg / test_copy_in_records

Function test_copy_in_records

tests/crdb/test_copy.py:122–135  ·  view source on GitHub ↗
(conn, format)

Source from the content-addressed store, hash-verified

120
121@pytest.mark.parametrize("format", pq.Format)
122def test_copy_in_records(conn, format):
123 cur = conn.cursor()
124 ensure_table(cur, sample_tabledef)
125
126 with cur.copy(f"copy copy_in from stdin {copyopt(format)}") as copy:
127 row: tuple[Any, ...]
128 for row in sample_records:
129 if format == pq.Format.BINARY:
130 row = tuple((Int4(i) if isinstance(i, int) else i for i in row))
131 copy.write_row(row)
132
133 cur.execute("select * from copy_in order by 1")
134 data = cur.fetchall()
135 assert data == sample_records
136
137
138@pytest.mark.parametrize("format", pq.Format)

Callers

nothing calls this directly

Calls 8

Int4Class · 0.85
copyoptFunction · 0.70
ensure_tableFunction · 0.50
cursorMethod · 0.45
copyMethod · 0.45
write_rowMethod · 0.45
executeMethod · 0.45
fetchallMethod · 0.45

Tested by

no test coverage detected