Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def connectDB():
- db = {
- 'user': 'root',
- 'password': '',
- 'database': 'g'
- }
- """ Connect to MySQL database """
- try:
- conn = mysql.connector.connect(host='localhost',
- database=db['database'],
- user=db['user'],
- password=db['password'])
- if conn.is_connected():
- print('Connected to MySQL database')
- cur = conn.cursor()
- cur.execute("SELECT * FROM apps_local")
- result = cur.fetchall()
- for record in result:
- url.append(record[11])
- except Error as e:
- print(e)
- finally:
- print("Closed MySQL")
- def insert():
- cur.execute("INSERT INTO...")
- cur.commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement