本文整理汇总了Python中MySQLdb.constants.FIELD_TYPE.TIMESTAMP属性的典型用法代码示例。如果您正苦于以下问题:Python FIELD_TYPE.TIMESTAMP属性的具体用法?Python FIELD_TYPE.TIMESTAMP怎么用?Python FIELD_TYPE.TIMESTAMP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类MySQLdb.constants.FIELD_TYPE
的用法示例。
在下文中一共展示了FIELD_TYPE.TIMESTAMP属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: query
# 需要导入模块: from MySQLdb.constants import FIELD_TYPE [as 别名]
# 或者: from MySQLdb.constants.FIELD_TYPE import TIMESTAMP [as 别名]
def query(self):
"""
Queries mysql and returns a cursor to the results.
"""
mysql = MySqlHook(mysql_conn_id=self.mysql_conn_id)
conn = mysql.get_conn()
cursor = conn.cursor()
if self.ensure_utc:
# Ensure TIMESTAMP results are in UTC
tz_query = "SET time_zone = '+00:00'"
self.log.info('Executing: %s', tz_query)
cursor.execute(tz_query)
self.log.info('Executing: %s', self.sql)
cursor.execute(self.sql)
return cursor
示例2: field_to_bigquery
# 需要导入模块: from MySQLdb.constants import FIELD_TYPE [as 别名]
# 或者: from MySQLdb.constants.FIELD_TYPE import TIMESTAMP [as 别名]
def field_to_bigquery(self, field):
field_type = self.type_map.get(field[1], "STRING")
# Always allow TIMESTAMP to be nullable. MySQLdb returns None types
# for required fields because some MySQL timestamps can't be
# represented by Python's datetime (e.g. 0000-00-00 00:00:00).
field_mode = "NULLABLE" if field[6] or field_type == "TIMESTAMP" else "REQUIRED"
return {
'name': field[0],
'type': field_type,
'mode': field_mode,
}