SHARE
TWEET

Untitled

a guest May 24th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top