Reading binary data from Postgres 9

From: Ian <youknowho2000(at)yahoo(dot)com>
To: "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org>
Subject: Reading binary data from Postgres 9
Date: 2011-08-19 00:28:28
Message-ID: 1313713708.22500.YahooMailNeo@web39415.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Hi list,

I am storing a NumPy array in binary form in Postgres with:

import numpy as np
...
my_array = np.array(data_list, np.float32)
cur.execute("insert into my_table values (%s)", (psycopg2.Binary(my_array),))

I've confirmed that this works fine. However when I query this binary data from the database I am having trouble deserializing/getting it back into a NumPy array. The result comes back as a read-only buffer. Does psycopg2 have an opposite of Binary to handle this?

Thanks.

Responses

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2011-08-19 10:40:53 Re: Reading binary data from Postgres 9
Previous Message Federico Di Gregorio 2011-08-18 13:32:38 Re: Vacancy!