Advertisement
Guest User

Untitled

a guest
May 24th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import MySQLdb
  2.  
  3. connection = MySQLdb.connect(
  4.                 host = 'localhost',
  5.                 user = 'root',
  6.                 passwd = 'admin')  # create the connection
  7.  
  8. cursor = connection.cursor()     # get the cursor
  9.  
  10.  
  11.  
  12. print("1. wyswietl baze")
  13. wybor = raw_input("wybierz opcje: ")
  14. if wybor=="1": #print("wybrales wybor bazy")
  15.  
  16.     cursor.execute("SHOW DATABASES")
  17.     connection.commit()
  18.     numrows = int(cursor.rowcount)
  19.     for x in range(0,numrows):
  20.         row = cursor.fetchone()
  21.         print row[0]
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. #cursor.execute("USE mysql") # select the database
  29.  
  30. #cursor.execute("SHOW TABLES")    # execute 'SHOW TABLES' (but data is not returned)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement