MCPcopy
hub / github.com/psycopg/psycopg / test_execute_binary

Function test_execute_binary

tests/test_cursor_server.py:119–133  ·  view source on GitHub ↗
(conn)

Source from the content-addressed store, hash-verified

117
118
119def test_execute_binary(conn):
120 cur = conn.cursor("foo")
121 cur.execute("select generate_series(1, 2)::int4", binary=True)
122 assert cur.fetchone() == (1,)
123 assert cur.pgresult.fformat(0) == 1
124 assert cur.pgresult.get_value(0, 0) == b"\x00\x00\x00\x01"
125 assert cur.fetchone() == (2,)
126 assert cur.pgresult.fformat(0) == 1
127 assert cur.pgresult.get_value(0, 0) == b"\x00\x00\x00\x02"
128
129 cur.execute("select generate_series(1, 1)::int4")
130 assert cur.fetchone() == (1,)
131 assert cur.pgresult.fformat(0) == 0
132 assert cur.pgresult.get_value(0, 0) == b"1"
133 cur.close()
134
135
136def test_binary_cursor_text_override(conn):

Callers

nothing calls this directly

Calls 6

cursorMethod · 0.45
executeMethod · 0.45
fetchoneMethod · 0.45
fformatMethod · 0.45
get_valueMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected