如何创建 ODBC“DSN"跨平台测试? [英] How to create ODBC "DSN" for cross-platform testing?
问题描述
我需要一个关于 WIN 的简单 ODBC 测试场景,我可以非常简单地配置它,并确保它正在支持 Unix.SE.
I need a simple ODBC test scenario on WIN which I can configure very simply and be assured it is working in support of another question at Unix.SE.
简而言之,我正在尝试在 KVM/QEMU 虚拟系统 (192.168.1.12) 中设置从 Debian 10 (192.168.1.2) 到 Windows 10 的 PyODBC/Python 脚本连接.
In a nutshell I'm trying to setup a PyODBC/Python script connection from Debian 10 (192.168.1.2) to Windows 10 in KVM/QEMU virtual system (192.168.1.12).
首先,在 Windows 10/KVM 上,我看到 ODBC Data Source Administrator
有一个选项卡 File DSN
和 Microsoft Text Driver
.我可以使用 FileDSN 来测试 Python PyODBC 与 ODBC 的连接吗?使用一个简单的 CSV 文件代替服务器?(我对 ODBC 的研究只发现正在运行的服务器实例).
First, on the Windows 10/KVM, I see the ODBC Data Source Administrator
has a tab File DSN
and Microsoft Text Driver
. Can I use FileDSN to test Python PyODBC connection to ODBC using a simple CSV file in place of Server?? (My research with ODBC only finds running server instances).
接下来,我尝试了什么:
Next, what I tried:
我在 Debian 上安装了 适用于 Linux 的 ODBC Microsoft 驱动程序.
关闭 Windows 10 防火墙,我可以双向 ping:
Shutdown the Windows 10 firewall, and I can ping in both directions:
$nmap -p 22 192.168.1.12
# Deb 赢
<代码>>Test-NetConnection 192.168.1.2 -p 22 # Win to Deb
> Test-NetConnection 192.168.1.2 -p 22
# Win to Deb
在 Windows 10/KVM 上,我添加了一个带有 Microsoft Text Driver 的 FileDSN.我创建了一个带有简单标题和一行数据的 CSV 文件(odbc_test_01.csv
)(IE.{'ID' : 1, 'NAME' : 'FOO'}
)
On Windows 10/KVM I added a FileDSN with Microsoft Text Driver. I created a CSV file (odbc_test_01.csv
) with simple header and one row of data (IE. {'ID' : 1, 'NAME' : 'FOO'}
)
创建了一个 Jupyter Notebook 以简化测试.这是我的连接字符串和结果:
Created a Jupyter Notebook to make testing easier. Here is my connection string and the results:
cn = pyodbc.connect(r'Driver={ODBC Driver 17 for SQL Server};' # Driver installed above
r'FILEDSN=odbc_test_01.csv;' # my attempt at FileDSN
r'SERVER=192.168.1.12;' # KVM IP tested with ping
r'Trusted_Connection=no;' # explicit; use UID/PWD
r'UID=<username>;' # Windows user name
r'PWD=<password>', # Windows user password
autocommit=True)
OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
使用相同的字符串从 Debian 命令行尝试 isql
:
isql -v -k ''Driver={ODBC Driver 17 for SQL Server};FILEDSN=odbc_test_01.csv;SERVER=192.168.1.12;Trusted_Connection=no;UID=
SO 上的类似页面:
使用 pyodbc 从 Linux 到 Windows SQL Server 进行身份验证一个>
Python pyodbc 使用 SQL Server 连接到 Sql Server身份验证
推荐答案
我创建了一个 SQLite 数据库.然后我添加了 用于 ODBC 的 SQLite 驱动程序.
I created an SQLite database. Then I added SQLite drivers for ODBC.
这篇关于如何创建 ODBC“DSN"跨平台测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!