• <legend id='vdZqX'><style id='vdZqX'><dir id='vdZqX'><q id='vdZqX'></q></dir></style></legend>

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

      <tfoot id='vdZqX'></tfoot>
        <bdo id='vdZqX'></bdo><ul id='vdZqX'></ul>

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

      1. M1 Mac 上的 Pyodbc

        时间:2023-08-21
          <tbody id='tSDSS'></tbody>
        <i id='tSDSS'><tr id='tSDSS'><dt id='tSDSS'><q id='tSDSS'><span id='tSDSS'><b id='tSDSS'><form id='tSDSS'><ins id='tSDSS'></ins><ul id='tSDSS'></ul><sub id='tSDSS'></sub></form><legend id='tSDSS'></legend><bdo id='tSDSS'><pre id='tSDSS'><center id='tSDSS'></center></pre></bdo></b><th id='tSDSS'></th></span></q></dt></tr></i><div id='tSDSS'><tfoot id='tSDSS'></tfoot><dl id='tSDSS'><fieldset id='tSDSS'></fieldset></dl></div>

            1. <small id='tSDSS'></small><noframes id='tSDSS'>

                <legend id='tSDSS'><style id='tSDSS'><dir id='tSDSS'><q id='tSDSS'></q></dir></style></legend>
              • <tfoot id='tSDSS'></tfoot>

                  <bdo id='tSDSS'></bdo><ul id='tSDSS'></ul>
                  本文介绍了M1 Mac 上的 Pyodbc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试使用 pyodbc 连接到 Microsoft sql server 数据库.我不断收到错误

                  I am trying to connect to a Microsoft sql server database using pyodbc. I keep getting the error

                  错误: ('01000', "[01000] [unixODBC][Driver Manager]无法打开 lib 'ODBC Driver 17 for SQL Server': 找不到文件 (0) (SQLDriverConnect)")

                  Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")

                  检查 pyodbc.drivers() 没有结果

                  我根据提供的说明安装了 Microsoft ODBC 驱动程序 这里:

                  I installed the Microsoft ODBC driver according to the instructions provided here:

                  我运行了 odbcinst -j 产生了

                  DRIVERS............: /etc/odbcinst.ini 
                  SYSTEM DATA SOURCES: /etc/odbc.ini 
                  FILE DATA SOURCES..: /etc/ODBCDataSources
                  USER DATA SOURCES..: /Users/pawannandakishore/.odbc.ini
                  SQLULEN Size.......: 8
                  SQLLEN Size........: 8
                  SQLSETPOSIROW Size.: 8
                  


                  但是当我到达 /etc 时,我找不到 odbcinst.iniodbc.ini.他们似乎在 opt/homebrew/Cellar/


                  but when I got to /etc, I cannot find either odbcinst.ini or odbc.ini. They are seem to be in opt/homebrew/Cellar/

                  我真的很感激这方面的帮助.

                  I would really appreciate some help on this.

                  推荐答案

                  UPD:

                  您实际上可以在容器中使用 pyodbc 但容器应该在 x86_64 架构容器中构建和执行.为此,您需要将 platform 添加到 docker-compose.yml 或在容器运行期间(使用 docker 时)提供参数.您需要确保使用 buildx 构建容器!

                  UPD:

                  You actually can use pyodbc in the container but the container should be built and executed in the x86_64 arch container. In order to do this, you need to add the platform either to docker-compose.yml or provide an argument during container run (when using docker). You need to make sure that you are building a container using buildx!

                  码头工人:

                  • docker buildx build --platform linux/amd64 -t myimage .
                  • docker run --platform linux/amd64 myimage bash

                  Docker-compose:

                  Docker-compose:

                  version: "3.9"
                  
                  services:
                    web:
                      image: myimage:latest
                      build:
                        context: ./
                      platform: linux/amd64
                  


                  原答案:

                  pyodbc 确实不支持 ARM 架构.我在 M1 上使用 pymssql 以连接到 MSSQL 服务器.


                  Original answer:

                  It's true that pyodbc does not support ARM architecture. I'm using pymssql on my M1 in order to connect to MSSQL server.

                  1. 您需要安装系统要求freetds-dev.对于 alpine 容器,它将是 apk add freetds-dev

                  1. You need to install the system requirement freetds-dev. For alpine container, it will be apk add freetds-dev

                  在 pip 要求中添加 pymssql 包.

                  In pip requirements add pymssql package.

                  使用简单脚本测试连接:

                  Test connection with simple script:

                  import pymssql
                  conn = pymssql.connect(server='mssql', user='SA', password='Passw@rd', database='master')
                  cursor = conn.cursor()
                  cursor.execute("""SELECT 1;""")
                  

                  1. SqlAlchemy 连接应该如下所示

                  SQLALCHEMY_DATABASE_URI = (
                      f"mssql+pymssql://{MSSQL_USER}:{MSSQL_PASSWORD}@{MSSQL_HOST}/{MSSQL_DB}?"
                  )
                  

                  如果您需要在 M1 上运行 MSSQL 数据库 - 这是我对这个问题的回答 https://stackoverflow.com/a/66919852/11515610

                  If you need to run MSSQL database on M1 - here my answer on this problem https://stackoverflow.com/a/66919852/11515610

                  相关链接:

                  • 自适应服务器连接失败(DB-Lib 错误消息 20002,严重性 9)

                  https://docs.sqlalchemy.org/en/14/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pymssql

                  https://docs.microsoft.com/en-us/sql/connect/python/pymssql/step-1-configure-development-environment-for-pymssql-python-development?view=sql-server-ver15

                  https://pymssql.readthedocs.io/en/stable/pymssql_examples.html

                  这篇关于M1 Mac 上的 Pyodbc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Docker 连接 SQL Server 容器非零代码:1 下一篇:PLSQL APPLE 推送通知

                  相关文章

                  最新文章

                      • <bdo id='GMckt'></bdo><ul id='GMckt'></ul>
                    1. <small id='GMckt'></small><noframes id='GMckt'>

                    2. <legend id='GMckt'><style id='GMckt'><dir id='GMckt'><q id='GMckt'></q></dir></style></legend>
                    3. <tfoot id='GMckt'></tfoot>

                      <i id='GMckt'><tr id='GMckt'><dt id='GMckt'><q id='GMckt'><span id='GMckt'><b id='GMckt'><form id='GMckt'><ins id='GMckt'></ins><ul id='GMckt'></ul><sub id='GMckt'></sub></form><legend id='GMckt'></legend><bdo id='GMckt'><pre id='GMckt'><center id='GMckt'></center></pre></bdo></b><th id='GMckt'></th></span></q></dt></tr></i><div id='GMckt'><tfoot id='GMckt'></tfoot><dl id='GMckt'><fieldset id='GMckt'></fieldset></dl></div>