Jsonb With Psycopg2 Realdictcursor
I have a postgresql 9.4 (aka mongodb killer ;-) ) and this simple schema : CREATE TABLE test (id SERIAL, name text, misc jsonb); now i populate this, if i make a select it will sh
Solution 1:
Current psycopg version (2.5.3) doesn't know the oid for the jsonb type. In order to support it it's enough to call:
import psycopg2.extras
psycopg2.extras.register_json(oid=3802, array_oid=3807, globally=True)
once in your project.
You can find further information in this ML message.
Solution 2:
Works out of the box with psycopg2 2.7.1 (not need to json.loads -- dictionaries are what come out of queries.)
sudo apt-get install libpq-dev
sudo pip install psycopg2 --upgrade
python -c "import psycopg2 ; print psycopg2.__version__"
2.7.1 (dt dec pq3 ext lo64)
Post a Comment for "Jsonb With Psycopg2 Realdictcursor"