我正在尝试通过Flask-SQLAlchemy将DateTime值恢复为UTC时区代码。
我检查了我的Postgresql数据库时区
bool containsItemName = stockList.Any(x => x.Item.Name.Equals("MyName", StringComparison.InvariantCultureIgnoreCase));
我尝试了这种方法:https://stackoverflow.com/a/26106482/169691(不起作用)
> show timezone;
UTC
有什么建议吗?
答案 0 :(得分:2)
遇到类似的问题。
或者对于基本字符串和整数参数,通常可以在URL的查询字符串中指定它们:
e = create_engine(“ mysql:// scott:tiger @ localhost / test?encoding = utf8”)
我输入了connect_args.options
并以
SQLALCHEMY_DATABASE_URI = 'postgres://{}:{}@{}:{}/{}?options=-c+timezone%3Dutc'.format(
PG_USER, PG_PASS, PG_HOST, PG_PORT, PG_NAME
)
为我修复。希望这会有所帮助。