Use python2.4 to access SQL Server in Linux (installation)

Source: Internet
Author: User

In the past, I used python to access MSSQL and used a module called pymssql, which was used only in windows. For more information, see
Http://pymssql.sourceforge.net /.

Now you need to access MSSQL in Python in Linux and install freetds (http://www.freetds.org /). Since the pymssql source code could not be downloaded these days, Debian also did not download this package, had to use the python MSSQL module (http://object-craft.com.au/projects/mssql/examples.html) mentioned in the freetds document, download down to execute Python setup according to the document. PY install,
Compilation error. The following prompt is displayed:
Running install
Running build
Running build_py
Running build_ext
Building 'mssqldb' Extension
Gcc-pthread-fno-strict-aliasing-dndebug-g-O3-wall-wstrict-prototypes-FPIC-dhave_freetds-acceleration-dhave_dbcurcmd-dhave_dbcurrow-dhave_dbisopt-release-Acceleration- i/usr/include-I/home/hjue/Python-2.4.2/include-I/home/hjue/Python-2.4.2-C databuf. c-o build/temp. linux-i686-2.4/databuf. O
In file encoded ded from databuf. C: 9:
Mssqldb. h: 59: Error: syntax error at '# 'token
Mssqldb. h: 59: Error: syntax error at '# 'token
Mssqldb. h: 59: Error: syntax error at '# 'token
Mssqldb. h: 68: Error: 'dbmaxchar 'undeclared here (not in a function)
Mssqldb. h: 71: Error: syntax error at '# 'token
Mssqldb. h: 71: Error: syntax error at '# 'token
Mssqldb. h: 71: Error: syntax error at '# 'token
Error: Command 'gcc 'failed with exit status 1

I checked it on Google mainly because some MSSQL variables are not defined.
Add the following code to mssqldb. h and run Python setup. py install again.

# Define dbmaxchar 256
# Ifdef have_freetds
Typedef unsigned char dbbit;
# Define prnumeric maxprecision
# Define db_max_prec maxprecision
# Define db_max_scale maxprecision
Typedef struct dbvarychar
{
Dbsmallint Len;
Dbchar STR [dbmaxchar];
} Dbvarychar;
# Endif

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.