Skip to content

Instantly share code, notes, and snippets.

@BexTuychiev
Last active July 21, 2020 05:18
Show Gist options
  • Save BexTuychiev/08404f919ba487755bd336c0d216f1f6 to your computer and use it in GitHub Desktop.
Save BexTuychiev/08404f919ba487755bd336c0d216f1f6 to your computer and use it in GitHub Desktop.
import mysql.connector
# Store the arguments in a dictionary
config = {
'user': 'bex',
'password': 'my_password',
'database': 'db_name',
'host': 'host_url'
}
try:
# Establish a connection with remote server
connection = mysql.connector.connect(**config)
print('Connection successful!')
except mysql.connector.Error as error:
print("Something is very wrong... Getting this error:\n", error)
finally:
connection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment