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

Function test_copy_in_records

tests/test_copy.py:443–456  ·  view source on GitHub ↗
(conn, format)

Source from the content-addressed store, hash-verified

441
442@pytest.mark.parametrize("format", pq.Format)
443def test_copy_in_records(conn, format):
444 cur = conn.cursor()
445 ensure_table(cur, sample_tabledef)
446
447 with cur.copy(f"copy copy_in from stdin (format {format.name})") as copy:
448 for row in sample_records:
449 if format == pq.Format.BINARY:
450 row2 = tuple((Int4(i) if isinstance(i, int) else i for i in row))
451 row = row2 # type: ignore[assignment]
452 copy.write_row(row)
453
454 cur.execute("select * from copy_in order by 1")
455 data = cur.fetchall()
456 assert data == sample_records
457
458
459@pytest.mark.parametrize("format", pq.Format)

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected