分类: Sybase
2010-08-06 16:58:07
tar -zxvf ceODBC-2.0.tar.gz阅读readme.txt安装需要的包python-dev
unixodbc
unixodbc-dev我选择rpm包安装了上面三个包rpm -vih /tmp/python-devel-2.4.3-27.el5.*rpm -vih /tmp/unixODBC-2.2.11-7.1.*rpm -vih /tmp/unixODBC-devel-2.2.11-7.1.编译python setup.py build安装python setup.py install测试Python 2.4.3 (#1, Jun 11 2009, 14:09:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ceODBC
>>> 无报错,则安装成功
>>>
安装到/opt/sqlanywhere11/目录将cat /opt/sqlanywhere11/bin64/sa_config.sh 文件的内容添加到 ~/.bash_profile#!/bin/sh
#
echo "iAnywhere Solutions, Inc. One Sybase Drive, Dublin, CA 94568, USA"
echo "Copyright (c) 2001-2008, iAnywhere Solutions, Inc. Portions copyright (c) "
echo "1988-2008, Sybase, Inc. All rights reserved. All unpublished rights reserved."
echo# comment the following to unset the SA location.
SQLANY11="/opt/sqlanywhere11"
export SQLANY11# comment the following lines to remove SA binaries from your path.
PATH="$SQLANY11/bin64:$SQLANY11/bin32:${PATH:-}"
export PATH
LD_LIBRARY_PATH="$SQLANY11/lib64:${LD_LIBRARY_PATH:-}"
LD_LIBRARY_PATH="$SQLANY11/lib32:${LD_LIBRARY_PATH:-}"
export LD_LIBRARY_PATH
内容如下:=====================分割线===============[x]
Driver=/opt/sqlanywhere11/lib64/libodbc.so
uid=DBA
pwd=SQL
ENG=node2_asiqdemo
CommLinks=tcp(host=10.25.115.20;port=2638)
DatabaseName=asiqdemo=====================分割线===============第一行:sybase的驱动第二行:用户第三行:密码第四行:要注意哦,是数据库服务器的名称node2_asiqdemo第五行:连接参数,是主机和端口第六行:数据库名
import ceODBCcon=ceODBC.connect('dsn=x;uid=DBA;pwd=SQL')
curser=con.cursor()
curser.execute("select count(1) from a1")for i in curser.fetchone():
print i
con.commit()执行脚本[root@vm12 ~]# python 3.py 表a1一共48行记录
48到此安装成功!2010-08-05