diff options
Diffstat (limited to 'rpkid/rpki/sql.py')
-rw-r--r-- | rpkid/rpki/sql.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/rpkid/rpki/sql.py b/rpkid/rpki/sql.py index c4c9a7ae..d4426680 100644 --- a/rpkid/rpki/sql.py +++ b/rpkid/rpki/sql.py @@ -59,13 +59,21 @@ class session(object): self.database = cfg.get("sql-database") self.password = cfg.get("sql-password") + self.conv = MySQLdb.converters.conversions.copy() + self.conv.update({ + rpki.sundial.datetime : MySQLdb.converters.DateTime2literal, + MySQLdb.converters.FIELD_TYPE.DATETIME : rpki.sundial.datetime.DateTime_or_None }) + self.cache = weakref.WeakValueDictionary() self.dirty = set() self.connect() def connect(self): - self.db = MySQLdb.connect(user = self.username, db = self.database, passwd = self.password) + self.db = MySQLdb.connect(user = self.username, + db = self.database, + passwd = self.password, + conv = self.conv) self.cur = self.db.cursor() self.db.autocommit(True) self.timestamp = rpki.sundial.now() |