Python操作MySql

  • 时间:
  • 浏览:1

(3)配置odbc /etc/odbc

c.execute(sql)

CPResure =

import pyodbc 

2、存储过程要还可以 output值

c = db.cursor()

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

[dsnName]

CPTimeout =

[dsnName]

client charset = utf-8

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

FileUsage = 1

c.close()

Database = oneicdb

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

Driver = FreeTDS

UsageCount = 1

[FreeTDS]

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

Trace = No

db.close()

1.linux下安装unixODBC

2.linux安装FreeTDS

c.fetchall()

host = server ip

tds Version = 8.0

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

FileUsage = 1

Description = FreeTDS

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

Servername = dsnName

tds Version = 7.0

[SQL Server]

port = 1433

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

client charset = UTF-8

c.fetchone()

一、linux客户端连接mssql server

host = server ip

Description = FreeTDS ODBC driver for MSSQL

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

Description = Odbc connection via FreeTDS

port = 1433

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

[egServer70]

1、存储过程还可以 直接返回值,机会返回4个多多值,没有存储过程里还要有:SET NOCOUNT ON

db = pyodbc.connect(strconn)  

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