HOME/Articles/

mysql example python show db (snippet)

Article Outline

Python mysql example 'python show db'

Modules used in program:

  • import mysql.connector

python python show db

Python mysql example: python show db

import mysql.connector

conn = mysql.connector.connect(
  host="localhost",
  user="root",
  passwd=""
)
db_cursor = conn.cursor()
db_cursor.execute("SHOW DATABASES")

for db in db_cursor:
  print(db)