Python Forum

Full Version: Problem with connection: Python + SQL Server
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi Everyone!

I try to connect Python with SQL Server (with Windows Authentication), but I have a problem with the output... The code is:

import pypyodbc 
import pyodbc 

cnxn = pyodbc.connect('driver={SQL Server};server=ABC123;database=DB1;trusted_connection=true')
cursor = cnxn.cursor()

query = "SELECT TOP 10 * FROM TABLE_EXAMPLE "
cursor.execute(query)
cnxn.commit()

cnxn.close() 
The error is:
cursor.execute(query)
Out[298]: <pyodbc.Cursor at 0xe461623030>
... someone knows what happens please?. I have Microsoft SQL Server 2014 and Python 3.6.1 | Anaconda 4.4.0

Thanks very much for the help!

Regards Carlos,
(Feb-13-2018, 02:27 PM)carlos_123 Wrote: [ -> ]The error is:
It's not an error cursor get executed,you just see the memory location of that operation in IPython.
To see a result of query example cursor.fetchone().
Returns the next row in the query, or None when no more data is available.
cursor.fetchall() Returns a list of all the remaining rows in the query.
Thanks very much, this is'nt a Problem...you are reight

I can execute now good