prinkov commented on issue #9339:
URL: https://github.com/apache/airflow/issues/9339#issuecomment-645638008


   > I thought pyodbc is part of Airflow's requirements? pyodbc should already 
be installed right?
   > https://github.com/apache/airflow/tree/master/requirements
   
   Hmm, if I install Airflow with command (in docker container or host machine):
   `pip install apache-airflow[all_dbs,crypto,jdbc,ssh,mysql,mssql]`
   
   and I trying make the queries from the engine obtained from the MsSqlHook, 
unfortunately I get the error that pyodbc is not installed.
   Although MsSqlHook itself working, since it uses pymssql.
   
   and trying to make requests queries from the engine obtained from the hook, 
unfortunately I get the error that pyodbc is not installed. Although MsSQLHook 
itself, since it uses pymssql.
   
   Thus, the behavior seems illogical. The hook always uses pymssql, and at the 
same time always gives pyodbc as the engine. And if the first will work, this 
does not guarantee that the second also
   
   
   My use case. I'm trying create table if not exists in ETL operator. And I 
don't know the database in advance.
   
       def execute(self, context):
           engine = self.db_api_hook.get_sqlalchemy_engine()
           if not (type(engine.dialect) == MSDialect_pyodbc or 
engine.dialect.has_table(engine, table)):
               create_table(engine)
           elif type(engine.dialect) == MSDialect_pyodbc:
               query = '''SELECT * FROM INFORMATION_SCHEMA.TABLES 
                   WHERE TABLE_NAME = '{table}' '''.format(table=table)
               tables = self.db_api_hook.get_records(query)
               if len(tables) == 0:
                   self.create_table(engine)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to