-
Notifications
You must be signed in to change notification settings - Fork 0
/
conn.py
40 lines (28 loc) · 1.07 KB
/
conn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import mysql.connector
# Replace these values with your MySQL server and database information
db_config = {
"host": "shopify.clkyu9vsrxwy.eu-north-1.rds.amazonaws.com",
"user": "admin",
"password": "ajit5455"
}
# Establish a connection to the MySQL server
connection = mysql.connector.connect(**db_config)
# Create a cursor object to interact with the database
cursor = connection.cursor()
# Execute a simple query (e.g., fetching version)
# cursor.execute("SELECT VERSION()")
# # Fetch and print the result
# data = cursor.fetchone()
# print(f"MySQL Database Version: {data[0]}")
# product_data = {
# "title": "The Archived Snowboard",
# "body_html": "This is a gift card for the store",
# "vendor": "Snowboard Vendor",
# "status": "archived",
# "price": 20.00,
# "stock": 20
# }
# insert_query = "INSERT INTO product (title, body_html, vendor,status,price,stock) VALUES (%(title)s, %(body_html)s, %(vendor)s, %(status)s, %(price)s, %(stock)s)"
# cursor.execute(insert_query, product_data)
# Commit the changes to the database
connection.commit()