Advertisement
Guest User

Untitled

a guest
Feb 4th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. '''
  2. Created on Feb 4, 2017
  3.  
  4. @author: thom
  5. '''
  6.  
  7. import mysql.connector
  8.  
  9. if __name__ == '__main__':
  10.     conn = mysql.connector.connect(host='localhost',
  11.                                        database='dbcst8265',
  12.                                        user='user1' ,
  13.                                        password='cst8265')
  14.     if conn.is_connected():
  15.         print('Connected to MySQL database')
  16.            
  17.     cursor = conn.cursor()
  18.    
  19.     query = ("select city from college")
  20.    
  21.     cursor.execute(query)
  22.    
  23.     for (city) in cursor:
  24.         print city[0]
  25.  
  26.     cursor.close()
  27.     conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement