summaryrefslogtreecommitdiff
path: root/lib/extensions.py
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2012-09-19 04:26:35 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2012-09-19 04:26:35 +0100
commit024f0dbada97fa5f9718f7d622dba232ac4ca65a (patch)
treefa3b5724d8b25f40ec9d5273165537fa641425ec /lib/extensions.py
parentb8e7f022560343c744e2576da478597a61f01575 (diff)
downloadpsycopg2-024f0dbada97fa5f9718f7d622dba232ac4ca65a.tar.gz
Added json typecaster
Diffstat (limited to 'lib/extensions.py')
-rw-r--r--lib/extensions.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/extensions.py b/lib/extensions.py
index bb8e3dd..066373c 100644
--- a/lib/extensions.py
+++ b/lib/extensions.py
@@ -150,6 +150,20 @@ class NoneAdapter(object):
return _null
+# Create default json typecasters for PostgreSQL 9.2 oids
+from psycopg2._json import create_json_typecasters
+
+try:
+ JSON, JSONARRAY = create_json_typecasters(114, 199)
+except ImportError:
+ pass
+else:
+ register_type(JSON)
+ register_type(JSONARRAY)
+
+del create_json_typecasters
+
+
# Add the "cleaned" version of the encodings to the key.
# When the encoding is set its name is cleaned up from - and _ and turned
# uppercase, so an encoding not respecting these rules wouldn't be found in the