PostgreSQL支持使用DateStyle属性指定日期格式,如此处所述:http://www.postgresql.org/docs/current/interactive/runtime-config-client.html#GUC-DATESTYLE(链接最初是到8.3版本的文档)。我找不到任何SQLAlchemy ORM文档参考来定义这个属性。是否可以实现?
conn = engine.connect()
conn.execute("SET DateStyle='somestring'")
# work with conn
from sqlalchemy import event
from sqlalchemy.engine import Engine
@event.listens_for(Engine, "connect")
def connect(dbapi_connection, connection_record):
cursor = dbapi_connection.cursor()
cursor.execute("SET DateStyle='somestring'")
cursor.close()