+ @staticmethod
+ # From pgdb, and simplify code
+ # this is **very different** from the python2 code !
+ def _quote(x):
+ if isinstance(x, DateTimeType):
+ x = str(x)
+ elif isinstance(x, bytes):
+ x = x.decode('utf-8')
+
+ if isinstance(x, str):
+ # don't double quote backslahes, this causes failure
+ # with e.g. the SFA code when it tries to spot slices
+ # created from fed4fire, which to my knowledge is the only
+ # place where a backslash is useful
+ # x = x.replace("\\", "\\\\")
+ x = x.replace("'", "''")
+ x = f"'{x}'"
+ elif isinstance(x, (int, float)):
+ pass
+ elif x is None:
+ x = 'NULL'
+ elif isinstance(x, (list, tuple, set)):
+ x = 'ARRAY[%s]' % ', '.join([str(PostgreSQL._quote(x)) for x in x])
+ elif hasattr(x, '__pg_repr__'):
+ x = x.__pg_repr__()
+ else:
+ raise PLCDBError('Cannot quote type %s' % type(x))
+ return x
+
+