airflow - 气流 - SQL Server 连接
问题描述
我有一个关于将后端连接从 SQLite 更改为 SQL Server 的问题。在为 传递正确的连接字符串后sql_alchemy_conn
,我运行以下命令airflow initdb
:我收到以下错误:
sqlalchemy.exc.ProgrammingError: (pyodbc.ProgrammingError) ('42000', "[42000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]一张表只能有一个时间戳列。因为表'task_reschedule'已经有一个,不能添加列'start_date'。 (2738) (SQLExecDirectW)") [SQL: '\nCREATE TABLE task_reschedule (\n\tid INTEGER NOT NULL IDENTITY(1,1), \n\ttask_id VARCHAR(250) ) NOT NULL,\n\tdag_id VARCHAR(250) NOT NULL,\n\texecution_date TIMESTAMP NOT NULL,\n\ttry_number INTEGER NOT NULL,\n\tstart_date TIMESTAMP NOT NULL,\n\tend_date TIMESTAMP NOT NULL,\n\ tduration INTEGER NOT NULL, \n\treschedule_date TIMESTAMP NOT NULL, \n\tPRIMARY KEY (id), \n\tCONSTRAINT task_reschedule_dag_task_date_fkey FOREIGN KEY(task_id, dag_id, execution_date) REFERENCES task_instance (task_id, dag_id,execution_date)\n)\n\n'](此错误的背景:http://sqlalche.me/e/f405 )
解决方案
所以这对我有用:在文件中:0a2a5b66e19d_add_task_reschedule_table.py
添加:
def mysql_datetime():
return mysql.DATETIME(timezone=True)
并替换任何具有timestamp()
以下内容的行:
sa.Column('execution_date', timestamp(), nullable=False, server_default=None),
有了这个:
sa.Column('execution_date', mysql_datetime(), nullable=False, server_default=None),
进行此更改后,上述错误就会消失,但我不确定是否还有其他意外后果。如果是这样,我将在此处更新或仅使用 MySQL 数据库。
推荐阅读
- html - 使用 .htaccess 文件从 URL 中删除 .html 不起作用
- r - 有一个自举数据对象,但希望每次试验的观察总和而不是 rstudio 中的整体聚合
- ios - Alamofire multipart 仅上传一张图片 ios
- azure-keyvault - 从部署在 VNET 中的 Azure 容器实例访问 KeyVault
- r - R中三点之间的插值
- scala - ReactiveMongo 使用 MongoConnectionOptions 连接
- regex - 具有多个过滤器的正则表达式
- azure - 使用 Azure API 管理的异步 IP 受限逻辑应用在调用重试 url 时出现授权错误
- kotlin - Sequence 实际上比 Iterable 更通用,还是更通用?
- android - 由于 Linux 权限错误,Android 设备模拟器失败