pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <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="y0eggqu" 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="csyai2e" 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="0yww22w" 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'>

                            主站蜘蛛池模板: 郑州宣传片拍摄-TVC广告片拍摄-微电影短视频制作-河南优柿文化传媒有限公司 | AGV无人叉车_激光叉车AGV_仓储AGV小车_AGV无人搬运车-南昌IKV机器人有限公司[官网] | 宽带办理,电信宽带,移动宽带,联通宽带,电信宽带办理,移动宽带办理,联通宽带办理 | 工业设计,人工智能,体验式3D展示的智能技术交流服务平台-纳金网 J.S.Bach 圣巴赫_高端背景音乐系统_官网 | 碳化硅,氮化硅,冰晶石,绢云母,氟化铝,白刚玉,棕刚玉,石墨,铝粉,铁粉,金属硅粉,金属铝粉,氧化铝粉,硅微粉,蓝晶石,红柱石,莫来石,粉煤灰,三聚磷酸钠,六偏磷酸钠,硫酸镁-皓泉新材料 | 硅胶管挤出机厂家_硅胶挤出机生产线_硅胶条挤出机_臣泽智能装备 贵州科比特-防雷公司厂家提供贵州防雷工程,防雷检测,防雷接地,防雷设备价格,防雷产品报价服务-贵州防雷检测公司 | 华禹护栏|锌钢护栏_阳台护栏_护栏厂家-华禹专注阳台护栏、楼梯栏杆、百叶窗、空调架、基坑护栏、道路护栏等锌钢护栏产品的生产销售。 | 不锈钢电动球阀_气动高压闸阀_旋塞疏水调节阀_全立阀门-来自温州工业阀门巨头企业 | TPE塑胶原料-PPA|杜邦pom工程塑料、PPSU|PCTG材料、PC/PBT价格-悦诚塑胶 | 采暖炉_取暖炉_生物质颗粒锅炉_颗粒壁炉_厂家加盟批发_烟台蓝澳采暖设备有限公司 | 全自动翻转振荡器-浸出式水平振荡器厂家-土壤干燥箱价格-常州普天仪器 | 接地电阻测试仪[厂家直销]_电缆故障测试仪[精准定位]_耐压测试仪-武汉南电至诚电力设备 | 培训中心-海南香蕉蛋糕加盟店技术翰香原中心官网总部 | 水热合成反应釜-防爆高压消解罐-西安常仪仪器设备有限公司 | 筒瓦厂家-仿古瓦-寺庙-古建琉璃瓦-宜兴市古典园林建筑陶瓷厂有限公司 | 盘式曝气器-微孔曝气器-管式曝气器-曝气盘-斜管填料 | 郑州市前程水处理有限公司 | 学叉车培训|叉车证报名|叉车查询|叉车证怎么考-工程机械培训网 | Akribis直线电机_直线模组_力矩电机_直线电机平台|雅科贝思Akribis-杭州摩森机电科技有限公司 | Copeland/谷轮压缩机,谷轮半封闭压缩机,谷轮涡旋压缩机,型号规格,技术参数,尺寸图片,价格经销商 CTP磁天平|小电容测量仪|阴阳极极化_双液系沸点测定仪|dsj电渗实验装置-南京桑力电子设备厂 | 一体化隔油提升设备-餐饮油水分离器-餐厨垃圾处理设备-隔油池-盐城金球环保产业发展有限公司 | 培训中心-海南香蕉蛋糕加盟店技术翰香原中心官网总部 | 体检车_移动CT车_CT检查车_CT车_深圳市艾克瑞电气有限公司移动CT体检车厂家-深圳市艾克瑞电气有限公司 | 卧涛科技有限公司科技项目申报公司|高新技术企业申报|专利申请 | 【星耀裂变】_企微SCRM_任务宝_视频号分销裂变_企业微信裂变增长_私域流量_裂变营销 | 一体化污水处理设备_生活污水处理设备_全自动加药装置厂家-明基环保 | 武汉印刷厂-不干胶标签印刷厂-武汉不干胶印刷-武汉标签印刷厂-武汉标签制作 - 善进特种标签印刷厂 | 制氮设备_PSA制氮机_激光切割制氮机_氮气机生产厂家-苏州西斯气体设备有限公司 | 安规_综合测试仪,电器安全性能综合测试仪,低压母线槽安规综合测试仪-青岛合众电子有限公司 | 盛源真空泵|空压机-浙江盛源空压机制造有限公司-【盛源官网】 | 隔离变压器-伺服变压器--输入输出电抗器-深圳市德而沃电气有限公司 | 一体式钢筋扫描仪-楼板测厚仪-裂缝检测仪-泰仕特(北京) | 磨煤机配件-高铬辊套-高铬衬板-立磨辊套-盐山县宏润电力设备有限公司 | 合肥触摸一体机_触摸查询机厂家_合肥拼接屏-安徽迅博智能科技 | 防腐储罐_塑料储罐_PE储罐厂家_淄博富邦滚塑防腐设备科技有限公司 | 水平筛厂家-三轴椭圆水平振动筛-泥沙震动筛设备_山东奥凯诺矿机 包装设计公司,产品包装设计|包装制作,包装盒定制厂家-汇包装【官方网站】 | 无线遥控更衣吊篮_IC卡更衣吊篮_电动更衣吊篮配件_煤矿更衣吊篮-力得电子 | 济宁工业提升门|济宁电动防火门|济宁快速堆积门-济宁市统一电动门有限公司 | 南京展台搭建-南京展会设计-南京展览设计公司-南京展厅展示设计-南京汇雅展览工程有限公司 | 海水晶,海水素,海水晶价格-潍坊滨海经济开发区强隆海水晶厂 | 四川成都干燥设备_回转筒干燥机_脉冲除尘器_输送设备_热风炉_成都川工星科机电设备有限公司 | 冷却塔风机厂家_静音冷却塔风机_冷却塔电机维修更换维修-广东特菱节能空调设备有限公司 |