2010-08-24 17 views

Respuesta

7

VER tablas

15 chars

45

a ser un poco más completa:

import MySQLdb 

connection = MySQLdb.connect(
       host = 'localhost', 
       user = 'myself', 
       passwd = 'mysecret') # create the connection 

cursor = connection.cursor()  # get the cursor 


cursor.execute("USE mydatabase") # select the database 

cursor.execute("SHOW TABLES") # execute 'SHOW TABLES' (but data is not returned) 

Ahora hay dos opciones:

tables = cursor.fetchall()  # return data from last query 

o iterar sobre el cursor:

for (table_name,) in cursor: 
     print(table_name) 
+0

este enlace tutorial no funciona – aimzy

+0

Pitty ... eliminaron todo el sitio web. Así que eliminé el enlace, gracias por tomar nota. – Remi

+0

Error de sintaxis de error en o cerca de "USE" LÍNEA 1: USE portal – ihue

Cuestiones relacionadas