久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <legend id='VjcIL'><style id='VjcIL'><dir id='VjcIL'><q id='VjcIL'></q></dir></style></legend>
      <bdo id='VjcIL'></bdo><ul id='VjcIL'></ul>

    1. <i id='VjcIL'><tr id='VjcIL'><dt id='VjcIL'><q id='VjcIL'><span id='VjcIL'><b id='VjcIL'><form id='VjcIL'><ins id='VjcIL'></ins><ul id='VjcIL'></ul><sub id='VjcIL'></sub></form><legend id='VjcIL'></legend><bdo id='VjcIL'><pre id='VjcIL'><center id='VjcIL'></center></pre></bdo></b><th id='VjcIL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VjcIL'><tfoot id='VjcIL'></tfoot><dl id='VjcIL'><fieldset id='VjcIL'></fieldset></dl></div>

        <small id='VjcIL'></small><noframes id='VjcIL'>

      1. <tfoot id='VjcIL'></tfoot>

        Apache Airflow - 使用 pymssql + SQLAlchemy 連接到 MS SQL

        Apache Airflow - Connection issue to MS SQL Server using pymssql + SQLAlchemy(Apache Airflow - 使用 pymssql + SQLAlchemy 連接到 MS SQL Server 的問題)
      2. <tfoot id='EDwNl'></tfoot>

        <small id='EDwNl'></small><noframes id='EDwNl'>

          <bdo id='EDwNl'></bdo><ul id='EDwNl'></ul>

                <i id='EDwNl'><tr id='EDwNl'><dt id='EDwNl'><q id='EDwNl'><span id='EDwNl'><b id='EDwNl'><form id='EDwNl'><ins id='EDwNl'></ins><ul id='EDwNl'></ul><sub id='EDwNl'></sub></form><legend id='EDwNl'></legend><bdo id='EDwNl'><pre id='EDwNl'><center id='EDwNl'></center></pre></bdo></b><th id='EDwNl'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='EDwNl'><tfoot id='EDwNl'></tfoot><dl id='EDwNl'><fieldset id='EDwNl'></fieldset></dl></div>
                    <tbody id='EDwNl'></tbody>
                • <legend id='EDwNl'><style id='EDwNl'><dir id='EDwNl'><q id='EDwNl'></q></dir></style></legend>
                • 本文介紹了Apache Airflow - 使用 pymssql + SQLAlchemy 連接到 MS SQL Server 的問題的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我在使用 pymssql 連接到 Apache Airflow 1.10.1 中的 Azure MS SQL Server 2014 數據庫時遇到問題.我想使用 Airflow 提供的 MsSqlHook 類,為了方便在 Airflow UI 中創建我的連接,然后使用 SqlAlchemy 為我的連接創建上下文管理器:

                  @contextmanagerdef mssql_session(dt_conn_id):sqla_engine = MsSqlHook(mssql_conn_id=dt_conn_id).get_sqlalchemy_engine()session = sessionmaker(bind=sqla_engine)()嘗試:讓步除了:會話回滾()增加別的:session.commit()最后:session.close()

                  但是當我這樣做時,當我運行請求時出現此錯誤:

                  <塊引用>

                  sqlalchemy.exc.InterfaceError: (pyodbc.InterfaceError) ('IM002','[IM002] [unixODBC][Driver Manager]未找到數據源名稱,并且沒有默認驅動程序指定 (0) (SQLDriverConnect)') (此背景錯誤在:

                  為了解決這個問題,我在從 MsSqlHook 繼承的新類中重載了 DbApiHook 中的 get_uri 方法,其中我建立了自己的連接字符串,但它根本不干凈...

                  感謝您的幫助

                  解決方案

                  你說得對.沒有簡單、直接的方法可以讓 Airflow 做你想做的事.我個人會在你的上下文管理器中構建 sqlalchemy 引擎,比如 create_engine(hook.get_uri().replace("://", "+pymssql://")) -- 然后我會把代碼扔到可重用的地方.

                  I am facing a problem to connect to an Azure MS SQL Server 2014 database in Apache Airflow 1.10.1 using pymssql. I want to use the MsSqlHook class provided by Airflow, for the convenience to create my connection in the Airflow UI, and then create a context manager for my connection using SqlAlchemy:

                  @contextmanager
                  def mssql_session(dt_conn_id):
                      sqla_engine = MsSqlHook(mssql_conn_id=dt_conn_id).get_sqlalchemy_engine()
                      session = sessionmaker(bind=sqla_engine)()
                      try:
                          yield session
                      except:
                          session.rollback()
                          raise
                      else:
                          session.commit()
                      finally:
                          session.close()
                  

                  But when I do that, I have this error when I run a request :

                  sqlalchemy.exc.InterfaceError: (pyodbc.InterfaceError) ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)') (Background on this error at: http://sqlalche.me/e/rvf5)

                  It seems come from pyodbc whereas I want to use pymssql (and in MsSqlHook, the method get_conn uses pymssql !)

                  I searched in the source code of Airflow the cause. I noticed that the method get_uri from the class DbApiHook (from which is inherited MsSqlHook) builds the connection string passed to SqlAlchemy like this:

                  '{conn.conn_type}://{login}{host}/{conn.schema}'

                  But conn.conn_type is simply equal to 'mssql' whereas we need to specify the DBAPI as described here: https://docs.sqlalchemy.org/en/latest/core/engines.html#microsoft-sql-server (for example : 'mssql+pymssql://scott:tiger@hostname:port/dbname')

                  So, by default, I think it uses pyodbc. But how can I set properly the conn_type of the connection to 'mssql+pymssql' instead of 'mssql' ? In the Airflow IU, you can simply select SQL server in a dropdown list, but not set as you want :

                  To work around the issue, I overload the get_uri method from DbApiHook in a new class I created inherited from MsSqlHook, and in which I build my own connection string, but it's not clean at all...

                  Thanks for any help

                  解決方案

                  You're right. There's no easy, straightforward way to get Airflow to do what you want. Personally I would build the sqlalchemy engine inside of your context manager, something like create_engine(hook.get_uri().replace("://", "+pymssql://")) -- then I would toss the code somewhere reusable.

                  這篇關于Apache Airflow - 使用 pymssql + SQLAlchemy 連接到 MS SQL Server 的問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數據庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發
                  How to create a login to a SQL Server instance?(如何創建對 SQL Server 實例的登錄?)
                  How to know the version and edition of SQL Server through registry search(如何通過注冊表搜索知道SQL Server的版本和版本)
                  Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會出現“數據類型轉換錯誤?使用 ExecuteNonQuery()?)
                  How to show an image from a DataGridView to a PictureBox?(如何將 DataGridView 中的圖像顯示到 PictureBox?)
                  WinForms application design - moving documents from SQL Server to file storage(WinForms 應用程序設計——將文檔從 SQL Server 移動到文件存儲)
                    <bdo id='MJsGC'></bdo><ul id='MJsGC'></ul>
                    <i id='MJsGC'><tr id='MJsGC'><dt id='MJsGC'><q id='MJsGC'><span id='MJsGC'><b id='MJsGC'><form id='MJsGC'><ins id='MJsGC'></ins><ul id='MJsGC'></ul><sub id='MJsGC'></sub></form><legend id='MJsGC'></legend><bdo id='MJsGC'><pre id='MJsGC'><center id='MJsGC'></center></pre></bdo></b><th id='MJsGC'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='MJsGC'><tfoot id='MJsGC'></tfoot><dl id='MJsGC'><fieldset id='MJsGC'></fieldset></dl></div>
                    <tfoot id='MJsGC'></tfoot><legend id='MJsGC'><style id='MJsGC'><dir id='MJsGC'><q id='MJsGC'></q></dir></style></legend>

                          <tbody id='MJsGC'></tbody>

                        <small id='MJsGC'></small><noframes id='MJsGC'>

                            主站蜘蛛池模板: 国产精品免费一区二区 | 日韩精品视频在线免费观看 | 成人免费观看男女羞羞视频 | 亚洲国产精品视频 | 黄色毛片视频 | 婷婷毛片 | 老牛影视av一区二区在线观看 | av一区二区在线观看 | 亚洲精品二区 | 精品日韩在线观看 | 四色永久| 99精品国产一区二区三区 | 午夜一级做a爰片久久毛片 精品综合 | 亚洲视频中文字幕 | 精品免费视频 | 国内精品久久久久 | 久久精品视频一区二区三区 | 中文字幕亚洲一区 | 国内精品视频免费观看 | www日| 99精品国产一区二区三区 | 91精品国产91久久久久久吃药 | 日韩高清中文字幕 | 成人伊人| 成人免费视频网址 | 91久久综合亚洲鲁鲁五月天 | 日韩精品一区二区三区在线观看 | 欧美啪啪网站 | 一区二区三区亚洲 | 九九亚洲精品 | www精品| 国产电影一区二区三区爱妃记 | 一区二区三区四区av | xxx视频| 国产高清在线视频 | 免费欧美 | 欧美日韩a| 久草资源 | 美女久久视频 | 日韩性生活网 | 国产婷婷色综合av蜜臀av |