pymssql

MSSQL in python 2.7

落花浮王杯 提交于 2019-11-27 19:51:00
问题 Is there a module available for connection of MSSQL and python 2.7? I downloaded pymssql but it is for python 2.6. Is there any equivalent module for python 2.7? I am not aware of it if anyone can provide links. Important note: in the meantime there is a pymssql module available. Don't miss to read the answer at the end of this page: https://stackoverflow.com/a/25749269/362951 回答1: You can also use pyodbc to connect to MSSQL from Python. An example from the documentation: import pyodbc cnxn =

mac - pip install pymssql error

回眸只為那壹抹淺笑 提交于 2019-11-27 19:02:05
I use Mac (OS X 10.11.5). I want to install module pymssql for python. In Terminal.app , I input sudo -H pip install pymssql , pip install pymssql , sudo pip install pymssql . But error occur. The directory /Users/janghyunsoo/Library/Caches/pip/http or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo , you may want sudo 's -H flag. The directory /Users/janghyunsoo/Library/Caches/pip or its parent directory is not owned by the current user and caching wheels has been

python连接sqlserver数据库

偶尔善良 提交于 2019-11-27 12:25:20
1.准备工作 python3.6连接sqlserver数据库需要引入pymssql模块 pymssql官方: https://pypi.org/project/pymssql/ 没有安装的话需要: pip安装: pip install pymssql 2.连接数据库 首先你得明确目标数据库的:'服务器名称',"账户名称","密码","数据库名称" 因为这些是必要的参数 这里使用本地数据库做测试: ​ 下面是链接语句: import pymssql #引入pymssql模块 def conn(): connect = pymssql.connect('(local)', 'sa', '**********', 'test') #服务器名,账户,密码,数据库名 if connect: print("连接成功!") return connect if __name__ == '__main__': conn = conn() 运行结果: 连接成功! Process finished with exit code 0 3.增删改查(CRUD) 创建一个新数据库表: import pymssql connect = pymssql.connect('(local)', 'sa', 'password1633', 'test') #建立连接 if connect: print("连接成功!")

pymssql: Connection to the database only works sometimes

不羁的心 提交于 2019-11-26 23:24:00
问题 I'm trying to connect to Azure SQL server using Python's pymssql. The problem is that the following script works but only sometimes, the other times I get this error: _mssql.MSSQLDatabaseException: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed\n') This is the script I'm using: import pymssql conn = pymssql.connect(server='x', user='x', password='x', database='x') cursor = conn.cursor() cursor.execute('SELECT * FROM customers'); row = cursor.fetchone()

How to configure pymssql with SSL support on Ubuntu?

南笙酒味 提交于 2019-11-26 22:56:51
What are the steps required to configure pymssql with SSL support on Ubuntu so I can connect to a SQL Server instance that requires an encrypted connection (e.g., Azure)? Ubuntu 16.04 LTS (See this answer for Ubuntu 18.04 LTS.) The following worked for me on a clean install of Xubuntu 16.04 LTS x64: The first challenge is that the FreeTDS we get from the Ubuntu 16.04 repositories does not support SSL "out of the box", so we need to build our own. Start by installing python3-pip (which also installs build-essentials, g++, and a bunch of other stuff we'll need) and libssl-dev (the OpenSSL

“ImportError: DLL load failed” when trying to import pymssql on Windows

允我心安 提交于 2019-11-26 22:08:15
问题 I'm trying to use the example code from here: http://www.pymssql.org/en/latest/pymssql_examples.html I installed the pymmsql module using pip . I also see it in the site-packages folder C:\Python27\Lib\site-packages\pymmsql.pyd But, when I execute the code, I get the following error: Traceback (most recent call last): File "C:\Android\android_workspace\pythonProject\test.py", line 2, in <module> import pymssql ImportError: DLL load failed: The specified module could not be found. What am I

mac - pip install pymssql error

不想你离开。 提交于 2019-11-26 19:43:13
问题 I use Mac (OS X 10.11.5). I want to install module pymssql for python. In Terminal.app , I input sudo -H pip install pymssql , pip install pymssql , sudo pip install pymssql . But error occur. The directory /Users/janghyunsoo/Library/Caches/pip/http or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo , you may want sudo 's -H flag. The directory /Users/janghyunsoo/Library

How do I use SQL parameters with python?

坚强是说给别人听的谎言 提交于 2019-11-26 12:33:07
I am using python 2.7 and pymssql 1.9.908 . In .net to query the database I would do something like this: using (SqlCommand com = new SqlCommand("select * from Customer where CustomerId = @CustomerId", connection)) { com.Parameters.AddWithValue("@CustomerID", CustomerID); //Do something with the command } I am trying to figure out what the equivalent is for python and more particularly pymssql. I realize that I could just do string formatting, however that doesn't seem handle escaping properly like a parameter does (I could be wrong on that). How do I do this in python? After creating a

How do I use SQL parameters with python?

纵然是瞬间 提交于 2019-11-26 04:02:12
问题 I am using python 2.7 and pymssql 1.9.908. In .net to query the database I would do something like this: using (SqlCommand com = new SqlCommand(\"select * from Customer where CustomerId = @CustomerId\", connection)) { com.Parameters.AddWithValue(\"@CustomerID\", CustomerID); //Do something with the command } I am trying to figure out what the equivalent is for python and more particularly pymssql. I realize that I could just do string formatting, however that doesn\'t seem handle escaping