安裝Sybase module for Python

1、下載Sybase module for Pythonpython

$ wget http://nchc.dl.sourceforge.net/project/python-sybase/python-sybase/python-sybase-0.40pre2/python-sybase-0.40pre2.tar.gzlinux

2、解壓sql

tar xzvf python-sybase-0.40pre2.tar.gz測試

3、修改setup.pyfetch

    把 sybase = '/opt/sybase' 改成sybase = '/opt/sybase/OCS-16_0'ui

4、編譯安裝.net

python setup.py buildcode

sudo python setup.py installorm

5、測試rem

$ python

Python 2.7.6 (default, Jun 22 2015, 17:58:13) 

[GCC 4.8.2] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import Sybase

>>> Sybase.connect('MYMOTIFVOSTRO145480', 'sa', 'wxwpxh')

若是沒有錯誤信息、說明安裝成功了

sybtest.py

import sys, string, Sybase

db = Sybase.connect('MYMOTIFVOSTRO145480', 'sa', 'wxwpxh')
c = db.cursor()
if len(sys.argv) > 1:
    c.execute('select c.text from syscomments c, sysobjects o'
              ' where o.name = @name and o.type = "P" and c.id = o.id'
              ' order by c.colid', {'@name': sys.argv[1]})
    print string.join([row[0] for row in c.fetchall()], '')
else:
    c.execute('select name from sysobjects where type = "P" order by name')
    print string.join([row[0] for row in c.fetchall()], '\n')

$ python sybtest.py

sp_addconf

sp_autoformat

sp_aux_checkroleperm

sp_aux_getsize

sp_check_remote_tempdb

sp_configure

sp_dboption

sp_dboption_flmode

sp_dropdevice

sp_getmessage

sp_instmsg

sp_loaddbupgrade

sp_namecrack

sp_probe_xact

sp_procxmode

sp_prtsybsysmsgs

sp_remotesql

sp_validlang

相關文章
相關標籤/搜索