File size: 867 Bytes
626d523
 
0c2a4c6
 
 
 
 
626d523
0c2a4c6
 
 
626d523
 
 
 
0c2a4c6
626d523
0c2a4c6
 
626d523
 
1a1368c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 

# HOST = "anuj-panthri-stupiddocker.hf.space"
# PORT = 3306
# USER = "root"
# PASSWORD = "secret"
HOST = "bnadwttldj2i5cq9aymp-mysql.services.clever-cloud.com"
PORT = 3306
USER = "uvfqvcypihhznd2u"
DBNAME = "bnadwttldj2i5cq9aymp"
PASSWORD = "CX6TBadRQYFqprozqDTo"


mydb = mysql.connector.connect(
  host=HOST,
  port=PORT,
  user=USER,
  password=PASSWORD,
  database=DBNAME
)

print(mydb)

cursor=mydb.cursor()
cursor.execute("drop table if exists users;")
cursor.execute(''' CREATE TABLE if not exists users (
  id INT PRIMARY KEY,
  name VARCHAR(255),
  email VARCHAR(255)
); ''')

cursor.execute(" INSERT INTO users VALUES (1, 'Alice', 'alice@example.com'); ")
cursor.execute(" INSERT INTO users VALUES (2, 'Bob', 'bob@example.com'); ")
cursor.execute(" INSERT INTO users VALUES (3, 'Charlie', 'charlie@example.com'); ")


mydb.commit()