diff --git a/pyproject.toml b/pyproject.toml index 0f09087..374d0fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "rda_python_common" -version = "2.0.20" +version = "2.1.1" authors = [ { name="Zaihua Ji", email="zji@ucar.edu" }, ] diff --git a/src/rda_python_common/pg_dbi.py b/src/rda_python_common/pg_dbi.py index e89a606..89bb495 100644 --- a/src/rda_python_common/pg_dbi.py +++ b/src/rda_python_common/pg_dbi.py @@ -20,17 +20,18 @@ from .pg_log import PgLOG class PgDBI(PgLOG): - - # PostgreSQL specified query timestamp format - fmtyr = lambda fn: "extract(year from {})::int".format(fn) - fmtqt = lambda fn: "extract(quarter from {})::int".format(fn) - fmtmn = lambda fn: "extract(month from {})::int".format(fn) - fmtdt = lambda fn: "date({})".format(fn) - fmtym = lambda fn: "to_char({}, 'yyyy-mm')".format(fn) - fmthr = lambda fn: "extract(hour from {})::int".format(fn) def __init__(self): super().__init__() # initialize parent class + + # PostgreSQL specified query timestamp format + self.fmtyr = lambda fn=self: "extract(year from {})::int".format(fn) + self.fmtqt = lambda fn=self: "extract(quarter from {})::int".format(fn) + self.fmtmn = lambda fn=self: "extract(month from {})::int".format(fn) + self.fmtdt = lambda fn=self: "date({})".format(fn) + self.fmtym = lambda fn=self: "to_char({}, 'yyyy-mm')".format(fn) + self.fmthr = lambda fn=self: "extract(hour from {})::int".format(fn) + self.pgdb = None # reference to a connected database object self.curtran = 0 # 0 - no transaction, 1 - in transaction self.NMISSES = [] # array of mising userno