with DBContext('w') as session: start_date = Common.get_month_and_day(day, '%Y-%m-%d 00:00:00') items = session.query(func.date_format(GitOperateLog.gol_datetime, '%Y-%m-%d'), func.count(GitOperateLog.gol_id)) \ .filter(GitOperateLog.gol_jira_project == project_name) \ .filter(GitOperateLog.gol_operate_code == GitOperateLogModel.GOL_OPERATE_CODE_MASTER_MERGE) \ .filter(GitOperateLog.gol_datetime >= start_date) \ .group_by(func.date_format(GitOperateLog.gol_datetime, '%Y-%m-%d')) \ .all() items = {i[0]: i[1] for i in items}

将时间格式化方法

func.date_format(Table.create_time, "%Y-%m-%d %H:%i:%s")

将时间戳转化成时间

func.from_unixtime((Table.timestamp), "%Y-%m-%d %H:%i:%s")