|
@@ -4,7 +4,7 @@
|
|
|
__author__ = 'Wang Liming'
|
|
|
|
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
|
-from sqlalchemy import Column, String, create_engine, Integer, DateTime, BigInteger, FLOAT
|
|
|
+from sqlalchemy import Column, String, create_engine, Integer, DateTime, BigInteger, FLOAT, TIMESTAMP, func
|
|
|
from urllib import parse
|
|
|
Base = declarative_base()
|
|
|
|
|
@@ -14,6 +14,8 @@ class BmsLastDataDay(Base):
|
|
|
__table_args__ = ({'comment': '电池信号监控---每天最后一条bms数据'}) # 添加索引和表注释
|
|
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True, comment="主键")
|
|
|
+ add_time = Column(TIMESTAMP(True), server_default=func.now()) # 创建时间
|
|
|
+ update_time = Column(TIMESTAMP(True), nullable=False, server_default=func.now(), onupdate=func.now()) # 更新时间
|
|
|
sn = Column(String(64), comment="sn")
|
|
|
current = Column(FLOAT, comment="电流")
|
|
|
time_stamp = Column(DateTime, comment="时间戳")
|
|
@@ -33,6 +35,8 @@ class GpsLastDataDay(Base):
|
|
|
__table_args__ = ({'comment': '电池信号监控---每天最后一条gps数据'}) # 添加索引和表注释
|
|
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True, comment="主键")
|
|
|
+ add_time = Column(TIMESTAMP(True), server_default=func.now()) # 创建时间
|
|
|
+ update_time = Column(TIMESTAMP(True), nullable=False, server_default=func.now(), onupdate=func.now()) # 更新时间
|
|
|
sn = Column(String(64), comment="sn")
|
|
|
time_stamp = Column(DateTime, comment="时间戳")
|
|
|
pack_state = Column(Integer, comment="电池状态")
|
|
@@ -50,10 +54,12 @@ class GpsSignalMonitor(Base):
|
|
|
__table_args__ = ({'comment': 'gps信号监控'}) # 添加索引和表注释
|
|
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True, comment="主键")
|
|
|
+ add_time = Column(TIMESTAMP(True), server_default=func.now()) # 创建时间
|
|
|
+ update_time = Column(TIMESTAMP(True), nullable=False, server_default=func.now(), onupdate=func.now()) # 更新时间
|
|
|
sn = Column(String(64), comment="sn")
|
|
|
start_time = Column(DateTime, comment="开始时间")
|
|
|
end_time = Column(DateTime, comment="结束时间")
|
|
|
- offline_time = Column(DateTime, comment="离线时间")
|
|
|
+ offline_time = Column(Integer, comment="离线时间")
|
|
|
pack_state = Column(Integer, comment="电池状态")
|
|
|
line_state = Column(Integer, comment="信号状态")
|
|
|
|
|
@@ -71,10 +77,12 @@ class BmsSignalMonitor(Base):
|
|
|
__table_args__ = ({'comment': 'bms信号监控'}) # 添加索引和表注释
|
|
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True, comment="主键")
|
|
|
+ add_time = Column(TIMESTAMP(True), server_default=func.now()) # 创建时间
|
|
|
+ update_time = Column(TIMESTAMP(True), nullable=False, server_default=func.now(), onupdate=func.now()) # 更新时间
|
|
|
sn = Column(String(64), comment="sn")
|
|
|
start_time = Column(DateTime, comment="开始时间")
|
|
|
end_time = Column(DateTime, comment="结束时间")
|
|
|
- offline_time = Column(DateTime, comment="离线时间")
|
|
|
+ offline_time = Column(Integer, comment="离线时间")
|
|
|
pack_state = Column(Integer, comment="电池状态")
|
|
|
line_state = Column(Integer, comment="信号状态")
|
|
|
|
|
@@ -94,7 +102,7 @@ if __name__ == "__main__":
|
|
|
user = 'qx_cas'
|
|
|
password = parse.quote_plus('Qx@123456')
|
|
|
database = 'qx_cas'
|
|
|
-
|
|
|
+
|
|
|
db_engine = create_engine(
|
|
|
"mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
|
|
|
user, password, host, port, database
|