Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Created on Feb 4, 2017
- @author: thom
- '''
- import mysql.connector
- if __name__ == '__main__':
- conn = mysql.connector.connect(host='localhost',
- database='dbcst8265',
- user='user1' ,
- password='cst8265')
- if conn.is_connected():
- print('Connected to MySQL database')
- cursor = conn.cursor()
- query = ("select city from college")
- cursor.execute(query)
- for (city) in cursor:
- print city[0]
- cursor.close()
- conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement