有人能帮助我吗?我试图在我的 Mac 上运行PyTest在我的venv环境中使用的 Python 自动化测试,但出现这样的错误:
库未加载:/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib
我尝试重新安装 openssl:
brew reinstall openssl@1.1
..........
A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /opt/homebrew/etc/openssl@1.1/certs
and run /opt/homebrew/opt/openssl@1.1/bin/c_rehash
openssl@1.1 is keg-only, which means it was not symlinked into /opt/homebrew, because macOS provides LibreSSL.
If you need to have openssl@1.1 first in your PATH, run: echo 'export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc
For compilers to find openssl@1.1 you may need to …Run Code Online (Sandbox Code Playgroud) 我尝试使用 Linux 机器中的 python 连接到 MSSQL DB (Python 2.7、Ubuntu 11.04)。我收到的输出被截断为 500 个字符。请参阅下面的脚本和配置。怎么解决呢?我认为问题出在 ODBC 驱动程序中或附近。
代码(pyodbc、pymssql):
conn = pymssql.connect(host='my_remote_host', user='ro_user',
password='password', database='current', as_dict=True)
cur = conn.cursor()
cur.execute(sql)
for i in cur:
print i
conn.close()
cnxn = pyodbc.connect(driver='FreeTDS', server='my_remote_host', database='current', uid='ro_user', pwd='password')
cursor = cnxn.cursor()
cursor.execute(sql)
rows = cursor.fetchall()
...
cnxn.close()
Run Code Online (Sandbox Code Playgroud)
我没有对 MS SQL DB 的写访问权限,它实际上是不属于我们系统的远程服务器。
sql = '''
SELECT Req.ID,
ShReq.Summary AS [Short Name],
ShReq.ALM_SharedText AS [Text],
Req.ContainedBy,
Req.DocumentID
FROM CurMKS..ALM_Requirement Req
JOIN CurMKS..ALM_SharedRequirement ShReq …Run Code Online (Sandbox Code Playgroud) 我想使用 pymssql 创建到 SQL Server 数据库的可信连接。鉴于该代码将被共享,我不希望用户输入他们的用户名或密码。我发现文档中关于如何实现这一点的信息相互矛盾。
我想要做的是类似的事情
engine = create_engine('mssql+pymssql://<Server>/<Database>?trusted=True')
Run Code Online (Sandbox Code Playgroud)
有些人说使用trust_connection=yes,其他人说使用trust=True。这些选项都不适合我。每次我尝试使用引擎时,我都会收到一条错误消息,指出trustedortrusted_connection是一个意外的关键字参数。
我使用的是 SQLAlchemy 1.0.9 版和 pymssql 2.1.1 版。
我无法在 Windows 10 上从 Python(3.4.4 64 位)连接到 SQL Server。这就是我所做的:
easy_install pymssql因此,此时我可以使用 SQL Server Management Studio 运行 SQL Server 并连接到我的数据库。当我登录时,我使用DESKTOP-1JA5E9F\SQLEXPRESS服务器名称、sa登录名和123密码。此外,在 Python shell 中,我可以pymssql像这样导入:
>>> import pymssql
Run Code Online (Sandbox Code Playgroud)
它不会引发任何错误。但是,我无法连接到我的数据库实例。我尝试了几十次尝试,例如:
conn = pymssql.connect(host=r'DESKTOP-1JA5E9F\SQLEXPRESS',
user=r'sa', password=r'123', database=r'reestr')
Run Code Online (Sandbox Code Playgroud)
^^^ 上面的代码永远不会完成(我看到只是_在外壳中闪烁,那是永远闪烁)。我也试过这个:
conn = pymssql.connect(host=r'SQLEXPRESS', user=r'sa', password=r'123', database=r'reestr')
Run Code Online (Sandbox Code Playgroud)
这导致pymssql.InterfaceError: Connection to the database failed for an unknown reason.. …
尝试连接到 SQL 服务器时,出现错误“TypeError:‘NoneType’类型的参数不可迭代”。我相信错误是在我连接到 SQL 服务器本身的线路上生成的,因为我的第二个打印语句从未使用过,尽管我可能是错的。
我正在使用 pymysql-2.1.3 和 python 3.5.1
server = getenv("####")
user = getenv("####")
password = getenv("####")
database = getenv("####")
print("hi")
conn = pymssql.connect(server, user, password, database)
print("hi2")
cursor = conn.cursor()
cursor.execute("####"
"SELECT Name, SourceTable, SourceTableID FROM dbo.Attachment WHERE Name LIKE '%icad%'")
conn.close()
print("Connect to SQL complete")
Run Code Online (Sandbox Code Playgroud)
这会导致错误:
Traceback (most recent call last):
hi
File "C:/convert.py", line 62, in <module>
connect_to_sql()
File "C:convert.py", line 15, in connect_to_sql
conn = pymssql.connect(server, user, password, database)
File "pymssql.pyx", line 635, in …Run Code Online (Sandbox Code Playgroud) grpidx_data=[]
for i in range(0,len(data1)):
grpidx_data.append((data1.loc[i,'price'],data1.loc[i,'id']))
cur.executemany("insert into grpidx values (%s,%s)",grpidx_data)
Run Code Online (Sandbox Code Playgroud)
我使用python3.3和pymssql。我想将数据从python导入到MSSQL。grpidx_data的类型是list(tuple),像[(12,1),(34,2),...],我运行上面的代码然后得到了错误:
ValueError:应为简单类型,元组或列表
如果我只使用list(tuple)类型的数据,则代码可以正常工作。但是,当我使用for循环获取数据时,即使其类型也为list(tuple),它也不起作用。
那么如何解决这个问题呢?
谢谢!
在Ubuntu上配置带有SSL支持的pymssql所需的步骤是什么,所以我可以连接到需要加密连接的SQL Server实例(例如Azure)?
我确信这个问题之前已经被提出过无数次,但也许有人仍然可以帮助我。
我正在使用 pymssql v2.1.3 和 Python 2.7.12,直到昨天我多次使用的代码将数据写入我的 Azure SQL DB 不知何故决定不再工作 - 没有明显的原因。
防火墙已设置,我的 IP 在白名单中,我可以使用 SQL Server Management Studio 连接到数据库并查询数据,但在尝试使用 pymssql 进行连接时,我仍然不断收到此错误。
该应用程序是一个 Flask 网络应用程序,以下是我连接到数据库的方式:
conn = pymssql.connect(server='myserver.database.windows.net', user='myusername@mydatabase', password='mypassword', database='mydatabase')
Run Code Online (Sandbox Code Playgroud) 我对Python开发很新,但很快就遇到了障碍,我不知道如何解决它.我使用Python 3.6和VS Code作为IDE,但我的机器上也安装了VS 2015 Express和VS 2017 Build Tools.我已经在VS Code中设置了我的项目,我已经能够安装几个依赖项pip了,但是我一直在尝试安装pymssql.
当我在终端上运行此命令时,出现以下错误:
PS C:\path\to\project> python -m pip install pymssql -t .\
Collecting pymssql
Using cached pymssql-2.1.3.tar.gz
Installing collected packages: pymssql
Running setup.py install for pymssql ... error
Complete output from command C:\...\Python\Python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\...\\Temp\\pip-build-sqfye0vh\\pymssql\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\...\pip-_407xunc-record\install-record.txt --single-version-externally-managed --compile --home=C:\...\Temp\tmpri_m4fvt:
setup.py: platform.system() => 'Windows'
setup.py: platform.architecture() => ('32bit', 'WindowsPE')
running install
running build
running build_ext
building '_mssql' extension
error: Microsoft …Run Code Online (Sandbox Code Playgroud) 我正在尝试连接到 Sybase 数据库并从中检索数据。我正在使用安装了 Anaconda 存储库的 Ubuntu 18.04 系统,并希望使用 Python 3.6。
\n\n我找到了一种使用 python-sybase 包从数据库检索数据的方法,但这依赖于 python 2.7,并且就我现在而言有点过时了。
\n\nimport Sybase\n\ndb = Sybase.connect(dsn = server:port, user = usr, passwd = pwd, database = db)\nc = db.cursor()\nc.execute("select var1,var2,var3 from xxx where datum=1yymmdd and statnr=stat1")\nlist1 = c.fetchall()\nprint list1\nRun Code Online (Sandbox Code Playgroud)\n\n该脚本的输出是这样的:
\n\n[(10.8, 100, 0), (11.2, 100, 5), (11.3, 100, 10), ..., ..., ...]\nRun Code Online (Sandbox Code Playgroud)\n\n我尝试改用 pymssql 包,它与 python 3.x 兼容。
\n\nimport pymssql\nconn = pymssql.connect(server=serv:port,user=usr,password=pwd,database=db)\nprint(conn)\ncursor = conn.cursor()\ncursor.execute("select var1,var2,var3 from xxx where datum=1yymmdd and statnr=stat1")\nlist2 …Run Code Online (Sandbox Code Playgroud) pymssql ×10
python ×9
sql-server ×3
apple-m1 ×1
homebrew ×1
list ×1
msbuild ×1
odbc ×1
openssl ×1
pyodbc ×1
python-3.x ×1
sqlalchemy ×1
sybase ×1
tuples ×1
ubuntu ×1