if not s: return "''" s = re_escape.sub(r'\\\1', s) if re_space.search(s): s = "'" + s + "'" return s # Create default json typecasters for PostgreSQL 9.2 oids from psycopg2._json import register_default_json, register_default_jsonb # noqa try: JSON, JSONARRAY = register_default_json() JSONB, JSONBARRAY = register_default_jsonb() except ImportError: pass del register_default_json, register_default_jsonb # Create default Range typecasters from psycopg2._range import Range # noqa del Range # 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 # encodings keys and would raise an exception with the unicode typecaster for k, v in list(encodings.items()): k = k.replace('_', '').replace('-', '').upper()
if not s: return "''" s = re_escape.sub(r'\\\1', s) if re_space.search(s): s = "'" + s + "'" return s # Create default json typecasters for PostgreSQL 9.2 oids from psycopg2._json import register_default_json, register_default_jsonb # noqa try: JSON, JSONARRAY = register_default_json() JSONB, JSONBARRAY = register_default_jsonb() except ImportError: pass del register_default_json, register_default_jsonb # Create default Range typecasters from psycopg2. _range import Range # noqa del Range # 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 # encodings keys and would raise an exception with the unicode typecaster