Python3 freetds.conf odbcinst.ini odbc.ini 之间的关系
三者分别是FreeTDS和UnixODBC的配置文件:
1,FreeTDS中的freetds.conf配置数据源:
# A typical Microsoft server [TEST1dsn] host = some sql server host like 192.168.100.9 port = 1433 tds version = 5.0
测试数据源:
tsql -S TEST1dsn -U root -P root -D dbtest
测试结果:
AndyMacBookPro:etc andy$ tsql -S TEST1dsn -U root -P root locale is "zh_CN.UTF-8" locale charset is "UTF-8" using default charset "UTF-8" 1>
2,UnixODBC里的odbcinst.ini指明odbc的驱动程序:
[FreeTDS] Description=freetds driver Driver=/usr/local/lib/libtdsodbc.so
数据源:TEST1dsn和驱动:FreeTDS,就都有了,下一步就真正开始配置可访问的UnixODBC的odbc.ini文件。
3,在UnixODBC中的odbc.ini中配置:
[andy1] Driver=FreeTDS #驱动名 Description=MSSQL Server Servername=TEST1dsn #数据源 Database=dbtest
这里指定了驱动是FreeTDS,数据源是 TEST1dsn,这两者都配置过了。
测试访问:
isql -v andy1 root root
测试结果:
AndyMacBookPro:etc andy$ isql -v andy1 root root +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL>
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/16678.html