python y sqlite3

Peon Blanco peonblanco83 en gmail.com
Sab Oct 21 17:45:58 CEST 2006


hola espero y me puedan  ayudar soy principiante tanto en python como en
sql

from sqlite3


conn = sqlite3.connect ("bandas.db")
cursor = conn.cursor ()

SQL = """INSERT INTO BANDAS (NOMBRE, P_ORIGEN, GENERO)
         VALUES ('EL RECODO', 'MEXICO','BANDA')"""
cursor.execute(SQL)
conn.commit()

SQL = "select NOMBRE, P_ORIGEN, GENERO from BANDAS order by NOMBRE"
cursor.execute(SQL)
row = cursor.fetchone()
plantilla = " %30s %15s %30s \n "
print plantilla % ('NOMBRE', 'P_ORIGEN', 'GENERO')

while row != None :
  print plantilla %   ( row ['NOMBRE'],
                        row ['P_ORIGEN'],
                        row ['GENERO']);
row = cursor.fetchone()
conn.close





IDLE 1.1.3
>>> ================================ RESTART
================================
>>>
                         NOMBRE              P_ORIGEN
GENERO


Traceback (most recent call last):
  File "C:\Documents and Settings\PEON\Escritorio\SQLite\consqlite.py", line
28, in -toplevel-
    print plantilla %   ( row ['NOMBRE'],
TypeError: tuple indices must be integers
>>>




Más información sobre la lista de distribución Python-es