Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # To connect to mariadb you would need to conda install the mysql-connector-python package
- import mysql.connector as mariadb
- # Connect to the DB
- connection = mariadb.connect(
- user='USERNAME',
- password='PASSWORD',
- database='employees',
- host='HOSTNAME_OF_MARIADB'
- )
- cursor = connection.cursor()
- # Execute the query
- cursor.execute("SELECT first_name, last_name FROM employees LIMIT 20")
- # Loop through the results
- for first_name, last_name in cursor:
- print(f'First name: {first_name}, Last name: {last_name}')
Add Comment
Please, Sign In to add comment