X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FPostgreSQL.py;h=ae6c55a0c22889c23f5b87c3a24241298002da18;hb=6e915d8a9ac5474c20482751ab6d24e6ce13aec9;hp=27a8ab4ff031c5dfbb2cf8ca9b5e10738a29fc6c;hpb=647e5fff4e77d6139637a483b3d74cee597060de;p=plcapi.git diff --git a/PLC/PostgreSQL.py b/PLC/PostgreSQL.py index 27a8ab4..ae6c55a 100644 --- a/PLC/PostgreSQL.py +++ b/PLC/PostgreSQL.py @@ -1,5 +1,5 @@ # -# PostgreSQL database interface. +# PostgreSQL database interface. # Sort of like DBI(3) (Database independent interface for Perl). # # Mark Huang @@ -13,7 +13,6 @@ psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) psycopg2.extensions.register_type(psycopg2._psycopg.UNICODEARRAY) import types -from types import StringTypes, NoneType import traceback import subprocess import re @@ -65,7 +64,7 @@ class PostgreSQL: x = str(x) elif isinstance(x, str): x = x.encode( 'utf-8' ) - + if isinstance(x, bytes): x = "'%s'" % str(x).replace("\\", "\\\\").replace("'", "''") elif isinstance(x, (int, float)): @@ -106,14 +105,14 @@ class PostgreSQL: @classmethod def param(self, name, value): # None is converted to the unquoted string NULL - if isinstance(value, NoneType): + if isinstance(value, type(None)): conversion = "s" # True and False are also converted to unquoted strings elif isinstance(value, bool): conversion = "s" elif isinstance(value, float): conversion = "f" - elif not isinstance(value, StringTypes): + elif not isinstance(value, str): conversion = "d" else: conversion = "s"