Skip to content

Instantly share code, notes, and snippets.

@apeiros
Created January 31, 2015 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apeiros/3ef8b75e9855f19d1e15 to your computer and use it in GitHub Desktop.
Save apeiros/3ef8b75e9855f19d1e15 to your computer and use it in GitHub Desktop.
pg.exec_params("CREATE TABLE foos (data bytea)")
para = Array.new(256).pack("C*") # => "\x00\x01\x02\x03\x04\x05…\xFE\xFF"
pg.exec_params("INSERT INTO foos ($1)", [para])
pg.exec_params("SELECT * FROM foos").to_a # => [{"data"=>"\\x"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment