1. python33连接sybase可以用pypyodbc
1) 简单连接调用程序
import pypyodbc
Config = {
'dsn':'test_db_XP',
}
conn = pypyodbc.connect("DSN=test_db_XP;UID=sa;pwd=")
cur = conn.cursor()
cur.execute('''
select * from t_test1
''')
cur.execute('''
create table dbo.t_test(id int)
''')
cur.commit()
cur.execute('''
insert into t_test(id) values(1)
''')
cur.commit()
pypyodbc是通过odbc驱动连接sybase的,所以在安装sybase时需要安装odbc驱动(默认安装未装)
2. 驱动配置, 在控制面板 --> 设置数据源(odbc),在设置系统DSN中配置别名为'test_db_XP的数据源
3. 遇见问题:
pypyodbc.Error: ('HY000', "[HY000] [DataDirect][ODBC Sybase Wire Protocol driver][SQL Server]The 'DROP TABLE' command is not allowed within a multi-statement transaction in the 'master' database.\n")
上述问题是由于