pymssql

Python 安装pymssql 报错 error:Microsoft Visual C++ 14.0 is required.

匿名 (未验证) 提交于 2019-12-02 22:51:30
平时都是对MySQL数据库进行操作的,今天想测试下SQL Server数据库是怎样的操作时,在安装model时报错,error:Microsoft Visual C++ 14.0 is required;阅读错误信息,好像是必须安装这个组件,但是我只是想安装一个pymssql的库。 查看pymssql官网: http://www.pymssql.org/en/stable/intro.html#install 安装 一般采用 pip install pymssql 的方式 也可以采用源代码的方式安装,windows上的轮子是.whl格式的 具体的.whl格式的库: https://www.lfd.uci.edu/~gohlke/pythonlibs/ 下载指定版本的pymssql包(pymssql-2.1.3-cp36-cp36m-win_amd64.whl),并把它放到python安装路径的Scripts文件夹下,然后cmd,cd到python安装路径;用pip install whl文件 文章来源: Python 安装pymssql 报错 error:Microsoft Visual C++ 14.0 is required.

Inserting through pymssql but no rows appear in the database

こ雲淡風輕ζ 提交于 2019-12-02 13:28:34
问题 Im quite new to python and im trying to write a script that puts values into a SQL database. its a simple 2 column table that looks like this: CREATE TABLE [dbo].[pythonInsertTest]( [ID] [int] IDENTITY(1,1) NOT NULL, [value] [varchar](50) NULL I tried doing a select query from python and that worked! So the connection or anything of that sort is not the problem. but when i'm inserting into the table with the following code: import pymssql conn = pymssql.connect(server='XXXX', user='XXXX',

Installing pymssql in Centos 6.6 64-bit

喜欢而已 提交于 2019-12-02 06:54:18
问题 I'm trying to pip install pymssql in my Centos 6.6, but kept on experiencing this error: _mssql.c:314:22: error: sqlfront.h: No such file or directory cpp_helpers.h:34:19: error: sybdb.h: No such file or directory I already installed freetds, freetds-devel, and cython. Any ideas? Thanks in advance! 回答1: Looking at the full traceback we see that include_dirs includes /usr/local/include but the header files are in /usr/include which I imagine has to do with the fact python 2.7 is not the system

Can Pymssql have a secure connection (SSL) to MS SQL Server?

不想你离开。 提交于 2019-12-02 03:25:34
问题 I'm making queries from a MS SQL server using Python code (Pymssql library) however I was wondering if there was any way to make the connection secure and encrypt the data being sent from the server to python? Thanks 回答1: pymssql certainly claims to be able to work with encrypted connections to the SQL Server (via OpenSSL). One reason why some might believe it to be impossible is that Windows releases of pymssql versions prior to 2.1.2 were shipped with pymssql statically linked to FreeTDS

Can Pymssql have a secure connection (SSL) to MS SQL Server?

為{幸葍}努か 提交于 2019-12-02 00:50:39
I'm making queries from a MS SQL server using Python code (Pymssql library) however I was wondering if there was any way to make the connection secure and encrypt the data being sent from the server to python? Thanks pymssql certainly claims to be able to work with encrypted connections to the SQL Server (via OpenSSL). One reason why some might believe it to be impossible is that Windows releases of pymssql versions prior to 2.1.2 were shipped with pymssql statically linked to FreeTDS for unencrypted connections only. Starting with version 2.1.2, the Windows release of pymssql is shipped

Python with MS SQL - truncated output

十年热恋 提交于 2019-12-01 19:49:26
I try to connect to MSSQL DB with python from Linux box ( Python 2.7 , Ubuntu 11.04 ) . Output that I receive is truncated to 500 characters. Please, see script and configs below. How it could be resolved? The problem I suppose in ODBC driver or near it. The code (pyodbc, pymssql): conn = pymssql.connect(host='my_remote_host', user='ro_user', password='password', database='current', as_dict=True) cur = conn.cursor() cur.execute(sql) for i in cur: print i conn.close() cnxn = pyodbc.connect(driver='FreeTDS', server='my_remote_host', database='current', uid='ro_user', pwd='password') cursor =

Unable to send Unicode to SQL Server using pymssql

扶醉桌前 提交于 2019-12-01 08:17:14
I'm having issues sending unicode to SQL Server via pymssql: In [1]: import pymssql conn = pymssql.connect(host='hostname', user='me', password='password', database='db') cursor = conn.cursor() In [2]: s = u'Monsieur le Curé of the «Notre-Dame-de-Grâce» neighborhood' In [3]: s Out [3]: u'Monsieur le Cur\xe9 of the \xabNotre-Dame-de-Gr\xe2ce\xbb neighborhood' In [4]: cursor.execute("INSERT INTO MyTable VALUES(%s)", s.encode('utf-8')) cursor.execute("INSERT INTO MyTable VALUES(" + s.encode('utf-8') + "')") conn.commit() Both execute statements yield the same garbled text on the SQL Server side:

Unable to send Unicode to SQL Server using pymssql

天大地大妈咪最大 提交于 2019-12-01 07:10:43
问题 I'm having issues sending unicode to SQL Server via pymssql: In [1]: import pymssql conn = pymssql.connect(host='hostname', user='me', password='password', database='db') cursor = conn.cursor() In [2]: s = u'Monsieur le Curé of the «Notre-Dame-de-Grâce» neighborhood' In [3]: s Out [3]: u'Monsieur le Cur\xe9 of the \xabNotre-Dame-de-Gr\xe2ce\xbb neighborhood' In [4]: cursor.execute("INSERT INTO MyTable VALUES(%s)", s.encode('utf-8')) cursor.execute("INSERT INTO MyTable VALUES(" + s.encode('utf

Insert binary file into MSSQL db (varbinary) with python pymssql

橙三吉。 提交于 2019-12-01 00:42:04
I'm trying to insert binary data into an MSSQL database using stored procedures from within an pyramid web application using pymssql. The MSSQL datatype for the respective column is varbinary(max) . My question is: What does the varbinary datatype of the MSSQL database expect me to do with the binary file before inserting it? Here's what I've been trying: with open(tmp_file, 'rb') as content_file: filecontent = content_file.read() ... and then pass the value of filecontent to the stored procedure. tmp_file in this case is a valid path to a .png file. The MSSQL db answers with the following

python 连接SQL SERVER 并读取其数据

风格不统一 提交于 2019-11-30 13:35:29
1、没什么难的操作 安装 pip install pymssql import pymssql #引入pymssql模块 import pandas as pd def conn(): connect = pymssql.connect('172.16.1.79','admin','admin','longshine') #服务器名,账户,密码,数据库名 if connect: print("连接成功!") return connect connect = pymssql.connect('172.16.1.77','admin','admin','longshine') #服务器名,账户,密码,数据库名 if connect: print("连接成功!") cursor = connect.cursor() # 创建一个游标对象,python里的sql语句都要通过cursor来执行 sql = ''' SELECT * FROM w_baoxiaomxywb ''' cursor.execute(sql) #执行sql语句 #row = cursor.fetchone() #读取查询结果, row = cursor.fetchall() print(pd.DataFrame(list(row)).shape) #connect.commit() # 提交 cursor.close