Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jordanlewis/d36d6cf455fe2ba64dd51c47112271a5 to your computer and use it in GitHub Desktop.
Save jordanlewis/d36d6cf455fe2ba64dd51c47112271a5 to your computer and use it in GitHub Desktop.
import psycopg2
binary = b'\xff\xd8\xff\xe0\x00\x10'
conn = psycopg2.connect('postgresql://root@localhost:26257/test?sslmode=disable')
with conn as conn, conn.cursor() as c:
c.execute('select %s::BYTEA', (binary, ))
rv, = c.fetchone()
rv = bytes(rv)
print('got', repr(rv), 'expected', repr(binary))
assert rv == binary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment