Python Forum
Problem with connection: Python + SQL Server
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with connection: Python + SQL Server
#1
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,
Reply
#2
(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.
Reply
#3
Thanks very much, this is'nt a Problem...you are reight

I can execute now good
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I don't know what is wrong (Python and SQL connection) shereen 3 323 Apr-01-2024, 08:56 AM
Last Post: Pedroski55
  No Internet connection when running a Python script basil_555 8 577 Mar-11-2024, 11:02 AM
Last Post: snippsat
  Connection LTspice-Python with PyLTSpice bartel90 0 336 Feb-05-2024, 11:46 AM
Last Post: bartel90
  Virtual Env changing mysql connection string in python Fredesetes 0 370 Dec-20-2023, 04:06 PM
Last Post: Fredesetes
  connection python and SQL dawid294 4 653 Dec-12-2023, 08:22 AM
Last Post: Pedroski55
  Networking Issues - Python GUI client and server connection always freezes Veritas_Vos_Liberabit24 0 717 Mar-21-2023, 03:18 AM
Last Post: Veritas_Vos_Liberabit24
  Mysql error message: Lost connection to MySQL server during query tomtom 6 15,992 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  pysql connection to cloud server database times out Pedroski55 9 4,709 Oct-11-2021, 10:34 PM
Last Post: Pedroski55
  Python MYSQL connection does not work after 1h idle zazas321 9 6,757 Oct-07-2021, 12:02 PM
Last Post: ndc85430
  Serial connection connection issue Joni_Engr 15 8,025 Aug-30-2021, 04:46 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020