MCPcopy
hub / github.com/psycopg/psycopg / test_copy_in_text_no_pinning

Function test_copy_in_text_no_pinning

tests/test_copy.py:499–523  ·  view source on GitHub ↗
(conn)

Source from the content-addressed store, hash-verified

497
498
499def test_copy_in_text_no_pinning(conn):
500 cur = conn.cursor()
501 cur.adapters.register_dumper(int, StrictIntDumper)
502
503 cols = [
504 "col1 serial primary key",
505 "col2 int",
506 "col3 int",
507 "col4 double precision",
508 "col5 double precision",
509 ]
510 ensure_table(cur, ",".join(cols))
511
512 with cur.copy(
513 "copy copy_in (col2,col3,col4,col5) from stdin (format text)"
514 ) as copy:
515 # no pinned dumpers: type check & cast done on postgres side
516 # allows to mix castable reprs more freely
517 # slower than pinned, late errors from postgres jeopardizing copy cursor
518 copy.write_row([1, "2", 3, "4.1"])
519 copy.write_row(["1", 2, 3.0, 4])
520
521 cur.execute("select col2,col3,col4,col5 from copy_in order by 1")
522 data = cur.fetchall()
523 assert data == [(1, 2, 3, 4.1), (1, 2, 3, 4)]
524
525
526def test_copy_in_text_pinned(conn):

Callers

nothing calls this directly

Calls 8

register_dumperMethod · 0.80
ensure_tableFunction · 0.70
cursorMethod · 0.45
joinMethod · 0.45
copyMethod · 0.45
write_rowMethod · 0.45
executeMethod · 0.45
fetchallMethod · 0.45

Tested by

no test coverage detected