Perl-connected MSSQL

Source: Internet
Author: User
Tags odbc connection install perl

SeeArticle: Http://space.itpub.net/82392/viewspace-238018

However, some functions cannot be used because they are too old.

 

# Install Perl
Yum install-y Perl *

# Install unixodbc
### Install the support library as needed
### Yum-y install automake Autoconf libtool

 
Wget FTP://Ftp.unixodbc.org/pub/unixodbc/unixodbc-2.3.1.tar.gzGunzipUnixodbc *.Tar. GZTarXvf unixodbc *.TarCD unixodbc-2.3.1./Configure -- prefix =/usr/local/unixodbc -- enable-Gui = NoMake Make Install

# Install the driver connecting to sqlserver or Sybase

 
WgetFtp://ftp.freetds.org/pub/freetds/stable/freetds-stable.tgz

TarVxzf freetds-stable.tgz
 
CD freetds-0.91/ 
./Configure -- prefix =/usr/local/freetds -- With-unixodbc =/usr/local/unixodbc -- With-tdsver = 8.0
Make
Make Install

Configure freetds. conf

Vim/usr/local/freetds/etc/freetds. conf# If the configuration file cannot be found, find/-name freetds. conf is available.

Add the following content:

 
[Sqlservercd] Host=# Hidden database IP address # Port=# Hidden Port # TDS version= 7.1

After that, you can test whether freetds can be successfully connected.

/Usr/local/freetds/bin/tsql-SSqlservercd-H# Hidden database IP address ##-P# Hidden Port ##-U # hidden username #-P # hidden password ##

# Install DBD-ODBC

 
Export odbchome =/usr/local/unixodbc
WgetHttp://mirrors.btte.net/CPAN/authors/id/M/MJ/MJEVANS/DBD-ODBC-1.37.tar.gzTar-Xzf DBD-ODBC-1.37.tar.gz
 
CDDBD-ODBC-1.37

Perl makefile. pl-O/usr/local/unixodbc

 

Make

Make Install

# Configure unixodbc

CD/usr/local/Unixodbcvim etc/Odbcinst. ini ##### Add the following content: [freetds] Driver=/Usr/local/freetds/lib/Libtdsodbc. So ##### save Vim etc/ODBC. ini ##### Add the following content [server1] Driver=Freetds; corresponds to the above freetds Server=# Hidden server address # Port=# Hidden Port Number # tds_version=7.2This item must be added; otherwise, what unexpect EOF ~~ will be reported to you ~~~ I found this item for almost two hours...

Complete the test:

Bin/iSQL-VServer1 ## hidden users #### hidden passwords ##

Then, share the ODBC Connection Library

CP/usr/local/unixodbc/lib/libodbc. */usr/lib

Test Perl

Vim test. pl

#! /Usr/bin/PerlUse dBi; $ DBH= DBI-> connect ('DBI: ODBC: server1', '# Hidden users ##',' # hidden passwords ##'); My $…= $ DBH-> prepare ("Select * from table"); $……->Execute ();While(@ DATA = $ something->Fetchrow_array () {print"$ Data [0] $ data [1] $ data [2] \ n";}

Save. Then explain the run

Perl test. pl

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.