Python操作MySql

  • 时间:
  • 浏览:2

Trace = No

(3)配置odbc /etc/odbc

host = server ip

CPResure =

UsageCount = 1

c.fetchone()

host = server ip

c.close()

[SQL Server]

import pyodbc 

2、存储过程不时要output值

client charset = UTF-8

c.execute(sql)

FileUsage = 1

Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so

Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so

(2)配置odbc /etc/odbc.ini

存储过程调用:c.execute("{call sp_MemberAdrInsert_py (?,?,?,?,?,?,?,?,?,?)}", ('a','b','c','d','e','f','g','h','1115086',0))

client charset = utf-8

port = 1433

1、存储过程时要直接返回值,因为返回两个多 值,这样存储过程里时要有:SET NOCOUNT ON

[egServer70]

2.linux安装FreeTDS

c = db.cursor()

strconn= 'DRIVER={SQL Server};SERVER=.;DATABASE=test;UID=sa;PWD=sa'  

tds Version = 8.0

db = pyodbc.connect(strconn)  

[dsnName]

FileUsage = 1

[dsnName]

Driver = FreeTDS

1.linux下安装unixODBC

(1) 配置FreeTDS。 /etc/freetds/freetds.conf

setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so

[FreeTDS]

port = 1433

Description = FreeTDS ODBC driver for MSSQL

Servername = dsnName

CPTimeout =

Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so

sql = '.....................'

Database = oneicdb

Welcome to Python world! I have a contract in this world! How about you?

tds Version = 7.0

一、linux客户端连接mssql server

Description = Odbc connection via FreeTDS

c.fetchall()

Description = FreeTDS

db.close()