In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The operating system is RHEL6.2
Install unixodbc and dependency packages
Yum-y install gcc gcc-c++ unixodbc unixODBC-devel python-devel
Install freetds
Tar xf freetds-stable.tgz
Cd freetds-0.91/
. / configure-- prefix=/usr/local/freetds-- with-unixodbc=/usr/-- with-tdsver=5.0
Make
Make install
Configure freetds and test the connection with tsql
Vim / usr/local/freetds/etc/freetds.conf
Add the following:
[Sybase]
Host = IP address
Port = port number
Tds version = 5.0
Client charset = UTF-8
The specific IP and port number can be replaced with what you need.
Test the connection:
/ usr/local/freetds/bin/tsql-S Sybase-U username-P password
If the following or similar content indicates a successful connection, you can try to execute some SQL statements at this time
Locale is "en_US.utf8"
Locale charset is "UTF-8"
Using default charset "UTF-8"
1 >
Configure unixodbc and test isql
Create the template file 1.txt of the driver as follows:
[TDS]
Description = Sybase
Setup = / usr/lib/libtdsS.so
Driver64 = / usr/local/freetds/lib/libtdsodbc.so
Driver = / usr/local/freetds/lib/libtdsodbc.so
Setup64 = / usr/lib64/libtdsS.so
FileUsage = 1
UsageCount = 2
Then use odbcinst to install the driver:
Odbcinst-I-d-f 1.txt
After the execution is complete, you can check the / etc/odbcinst.ini. If you can see the contents of the TDS, the configuration is fine.
You can also check the driver with odbcinst-Q-d
Create a template file for the data source, as follows:
[xiaosu]
Driver = TDS
Descrption = Sybase Server
Trace = No
Server = IP address
Database = database
Port = port number
The Database,IP address and port number here can be replaced with what you need.
Odbcinst-I-s-f 2.txt
After the execution is completed, the .odbc.ini file is generated in the user's home directory. Vim ~ / .odbc.ini can check the contents of the file. You can also use odbcinst-Q-s to check available data sources
Test the connection with isql: isql-v xiaosu username and password
If the following appears, the connection is successful.
+-+
| | Connected! |
| | |
| | sql-statement |
| | help [tablename] |
| | quit |
| | |
+-+
SQL >
Compile and install pyodbc
Unzip pyodbc-3.0.7.zip
Cd pyodbc-3.0.7
Python setup.py install
Test pyodbc connection
Create a new xiaosu.py as follows:
Import pyodbcconn=pyodbc.connect ("DSN=xiaosu;UID=uid;pwd=password") cursor=conn.cursor () cursor.execute ("select name from sysobjects where type ='U'") for i in cursor: print I
If python xiaosu.py can print out all the tables in the database, it is successful.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.