Python SQLServer Connect

Trying to run one of the google samples from


conn = pymssql.connect(host='localhost', user='sa', password='master', database='tempdb')
cur = conn.cursor()
cur.execute('CREATE TABLE persons(id INT, name VARCHAR(100))')
cur.executemany("INSERT INTO persons VALUES(%d, %s)", \
    [ (1, 'John Doe'), (2, 'Jane Doe') ])
conn.commit()  # you must call commit() to persist your data if you don't set autocommit to True


When I run python i get :
Traceback (most recent call last):
  File "", line 1, in <module>
    import pymssql
  File "C:\Python34\", line 3, in <module>
    conn = pymssql.connect(server="A117078\SQLEXPRESS", user="sa", password="mas
ter", database="tempdb")
AttributeError: 'module' object has no attribute 'connect'

Is there something wrong with the very first line, the import pymssql?
Assuming, probably incorrectly the 'connect' that has no attribute ties back in to the line 1 error?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have to install the module from here:

Modules are often like plugins that are outside python and they have to be installed separately. I am using the more popular pyodbc module or for Python > 3.3 version pypyodbc to connect to SQL server but that one should work too.
I think I misunderstood. What version of python do you use?
Ok, you are using version 3.4, you need to use pypyodbc instead. Some modules didn't keep up with python newest versions.

It can be used exactly as pyodbc where you can learn here:
Ok, me again. I noticed there is a pymssql verson for 3.4 so make sure you have that one installed:

Use this package:

pymssql-2.0.1.win32-py3.4.exe (md5)      MS Windows installer      3.4      2013-10-28      436KB

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
xoxomosAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.