久久久久久久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 的問題的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

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

                  @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()

                  但是當(dāng)我這樣做時,當(dāng)我運(yùn)行請求時出現(xiàn)此錯誤:

                  <塊引用>

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

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

                  感謝您的幫助

                  解決方案

                  你說得對.沒有簡單、直接的方法可以讓 Airflow 做你想做的事.我個人會在你的上下文管理器中構(gòu)建 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.

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

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

                  相關(guān)文檔推薦

                  Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數(shù)據(jù)庫列表和 SQL Server 實(shí)例使用的空間嗎?) - IT屋-程序員軟件開發(fā)
                  How to create a login to a SQL Server instance?(如何創(chuàng)建對 SQL Server 實(shí)例的登錄?)
                  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()?(為什么會出現(xiàn)“數(shù)據(jù)類型轉(zhuǎn)換錯誤?使用 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 應(yīng)用程序設(shè)計——將文檔從 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'>

                            主站蜘蛛池模板: 亚洲综合无码一区二区 | 午夜精品福利视频 | 国产精品视频在线观看 | 91黄在线观看 | 97国产精品视频人人做人人爱 | 欧美一级片在线观看 | 日韩视频观看 | 黄色片免费看视频 | 成年人在线观看视频 | 九九综合 | 日本精品久久久久久久 | 国产精品成人一区二区三区 | 亚洲成人国产 | 欧美乱码精品一区二区三区 | 国产精品久久久久久二区 | 男女免费观看在线爽爽爽视频 | 亚洲成人国产综合 | 免费午夜视频 | 成人做爰9片免费看网站 | 日韩欧美精品一区 | 国产精品日产欧美久久久久 | 2018国产精品 | 欧美日韩电影免费观看 | 国产成人精品一区二区三区四区 | 欧美一级免费观看 | 天堂一区二区三区四区 | 国产午夜亚洲精品不卡 | 97色伦网 | 国产精品久久久久久久久久妞妞 | 一级毛片,一级毛片 | 综合久久综合久久 | 欧美一级在线观看 | 精品国产乱码久久久久久蜜退臀 | 久久精品无码一区二区三区 | 欧美精品在线免费观看 | 国产九九九| 精品免费视频 | 中文在线视频 | 日韩成人性视频 | 午夜在线 | 国产精品久久久久久久久久久久久 |