Sie sind auf Seite 1von 1

Conexin a base de datos sql server

import pypyodbc as pod


conexion = pod.connect("DRIVER={SQL Server};SERVER=VIRTUAL-W7;DATABASE=Prueba")
cursor = conexion.cursor()
cursor.execute("insert into Usuarios(Nombre,Edad,Hobbies) values ('Giancarlo',28,'internet')")
coneccion.commit()

coneccion = pod.connect("DRIVER={SQL Server};SERVER=VIRTUAL-W7;DATABASE=Prueba")


cursor = coneccion.cursor()
cursor.execute("select ID,Nombre from Usuarios")
#coneccion.commit()
#row = cursor.fetchone()
#if row:
# print row
while 1:
row = cursor.fetchone()
if not row:
break
print 'id:', row[0]

Das könnte Ihnen auch gefallen