I am trying to print all the lines of a database, it does not give me an error, but it does not print either. I don't know where the error is.
import pyodbc
try:
conexion = pyodbc.connect('DRIVER=ODBC Driver 17 for SQL Server;SERVER=DESKTOP-NPCMMNO\SQLEXPRESS01;DATABASE=Farmatic;UID=sa;PWD=farmatic')
print('Conectado')
except:
print('error al intentar conectarse')
#consulta a la base de datos
cursor = conexion.cursor()
cursor.execute("SELECT * from dbo.InventaMA;")
inventario = cursor.fetchone()
while inventario:
print(inventario)
inventario = cursor.fetchone()
cursor.close()
conexion.close()
'''