Created
May 20, 2022 15:01
-
-
Save Hilal-Urun/eeb0b55472a6e0100cbf7319c9bc4ad4 to your computer and use it in GitHub Desktop.
sqlConnection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install install mysql-connector-python | |
import mysql.connector | |
from mysql.connector import Error | |
connection = mysql.connector.connect(host='db-mysql-fra1-08423-do-user-8476727-0.b.db.ondigitalocean.com', | |
database='defaultdb', | |
port='25060', | |
user='doadmin', | |
password='AVNS_gVLHcpWOtMuGqTO') | |
if connection.is_connected(): | |
db_Info = connection.get_server_info() | |
print("Connected to MySQL Server version ", db_Info) | |
cursor = connection.cursor() | |
cursor.execute("select database();") | |
record = cursor.fetchone() | |
print("You're connected to database: ", record) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment