Chinaunix首页 | 论坛 | 博客
  • 博客访问: 830857
  • 博文数量: 105
  • 博客积分: 636
  • 博客等级: 中士
  • 技术积分: 1704
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-11 10:57
文章分类

全部博文(105)

文章存档

2017年(4)

2016年(9)

2015年(18)

2014年(16)

2013年(34)

2012年(24)

分类: Python/Ruby

2015-07-03 17:59:54

菜鸟一枚 初次编写python脚本,用来连接mssql server ,把操作和遇到的问题记录下来。
系统:rhel 6.2 64位
python:Python 2.6.6
1.连接mssql server 用的pymssql模块。为了方便安装 用到pip工具,于是先安装pip
参考这个网址下载安装pip
执行命令为python get-pip.py
这个包最后包括Successfully installed argparse-1.3.0 pip-7.1.0 setuptools-18.0.1 wheel-0.24.0
2.安装pip命令后就可以用这个命令安装其它的包,但是此时用pip安装pymssql时需要提前安装python-devel
否则会出现如下错误
/tmp/pip-build-SQ3739/Cython/Cython/Plex/Scanners.c:18:6: error: #error Pyth
on headers needed to compile C extensions, please install development version of
 Python.
    error: command 'gcc' failed with exit status 1
3.rpm -ivh  python-devel-2.6.6-29.el6.x86_64.rpm
4.  pip install Cython
5.  安装freetds 包,可以到网站 下载,查看怎样安装
./configure --with-tdsver=8.0 --enable-msdblib --enable-shared --enable-static
make  && make install
6.  pip install pymssql
    此处如果不安装freetds 会报错误
7.此时需要的依赖包已经装好 进入python
>>> import pymssql
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: libsybdb.so.5: cannot open shared object file: No such file or dire
ctory
这是找不到类库
ln -s /usr/local/lib/lib* /usr/lib
ldconfig
在执行 import pymssql 就ok了
具体操作 可以参考此网页 pymssql 对库的操作。 />





阅读(4785) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~