From 32754fd8fa09448624580f3ecc50cb1d5d381c83 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Fri, 5 Oct 2012 00:01:41 -0400 Subject: [PATCH] support current timestamp --- PLC/Storage/AlchemyObject.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/PLC/Storage/AlchemyObject.py b/PLC/Storage/AlchemyObject.py index 98f1a61b..4ddcba60 100644 --- a/PLC/Storage/AlchemyObject.py +++ b/PLC/Storage/AlchemyObject.py @@ -2,8 +2,7 @@ from datetime import datetime from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Table, Column, MetaData, join, ForeignKey -from sqlalchemy import Column, Integer, String -from sqlalchemy import Table, Column, MetaData, join, ForeignKey +from sqlalchemy import Column, Integer, String, TIMESTAMP from sqlalchemy.orm import relationship, backref from sqlalchemy.orm import column_property from sqlalchemy.orm import mapper, object_mapper @@ -34,6 +33,7 @@ class AlchemyObj(Record): table = Table(self.tablename, metadata) for field in self.fields: param = self.fields[field] + args = {} # skip params joined from other tables if param.joined: continue @@ -41,11 +41,13 @@ class AlchemyObj(Record): if param.type == int: type = Integer elif param.type == datetime: - type = DateTime + type = TIMESTAMP + column = Column(field, type, nullable = param.nullok, index = param.indexed, - primary_key=param.primary_key) + primary_key=param.primary_key, + default=param.default) table.append_column(column) if not table.exists(): table.create() -- 2.47.0