在Windows中使用Python 3连接到Sql Server

时间:2022-01-30 01:40:50

Can someone please point me in the right direction of how I can connect to MS SQL Server with Python? What I want to do is read a text file, extract some values and then insert the values from the text file into a table in my Sql Server database. I am using Python 3.1.3, and it seems some of the modules I have come across in research online are not included in the library. Am I missing something? Is there a good 3rd party module I should know about. Any help would be greatly appreciated.I am using Windows. thanks

谁能告诉我如何用Python连接到MS SQL Server ?我要做的是读取一个文本文件,提取一些值,然后将文本文件中的值插入到Sql Server数据库中的一个表中。我使用的是Python 3.1.3,它似乎是我在网络研究中遇到的一些模块,它们并不包括在库中。我遗漏了什么东西?是否有一个好的第三方模块我应该知道。如有任何帮助,我们将不胜感激。我使用Windows。谢谢

3 个解决方案

#1


3  

There are a bunch more SQL Server libraries listed on the Python wiki. At least mxODBC is fully ready for Python 3.1, but I haven't used it so I can't comment on its appropriateness...

Python wiki上列出了更多的SQL服务器库。至少mxODBC已经为Python 3.1做好了充分准备,但是我还没有使用它,所以我不能评论它的适用性……

#2


1  

There is a pymssql module. Here you can find installation instructions

有一个pymssql模块。在这里你可以找到安装说明

#3


1  

I found a module called CEODBC that I was able to use with Python 3 after doing some research. It looks like they will also be releasing a Python3 compatible version of PYODBC soon. Thanks for all your help.

在做了一些研究之后,我发现了一个叫做CEODBC的模块,我可以用Python 3来使用它。看起来他们很快也会发布兼容python版本的PYODBC。谢谢你的帮助。

#1


3  

There are a bunch more SQL Server libraries listed on the Python wiki. At least mxODBC is fully ready for Python 3.1, but I haven't used it so I can't comment on its appropriateness...

Python wiki上列出了更多的SQL服务器库。至少mxODBC已经为Python 3.1做好了充分准备,但是我还没有使用它,所以我不能评论它的适用性……

#2


1  

There is a pymssql module. Here you can find installation instructions

有一个pymssql模块。在这里你可以找到安装说明

#3


1  

I found a module called CEODBC that I was able to use with Python 3 after doing some research. It looks like they will also be releasing a Python3 compatible version of PYODBC soon. Thanks for all your help.

在做了一些研究之后,我发现了一个叫做CEODBC的模块,我可以用Python 3来使用它。看起来他们很快也会发布兼容python版本的PYODBC。谢谢你的帮助。