0% found this document useful (0 votes)
8 views1 page

Fitness DB Creation Text

Uploaded by

thiagarajan s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Fitness DB Creation Text

Uploaded by

thiagarajan s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

10/27/24, 3:44 PM fitnees_db.

py

fitnees_db.py

1 import mysql.connector as sql # Import MySQL connector for interacting with the database
2
3 # Establish a connection to MySQL server with the specified credentials
4 conn = sql.connect(
5 host="localhost",
6 user="root",
7 password="1234"
8 )
9
10 # Check if the connection to the MySQL server is successful
11 if conn.is_connected():
12 print("Successfully connected")
13
14 # Create a new database named "fitness"
15 conn.cursor().execute("CREATE DATABASE fitness")
16 print("Database Successfully Created")
17
18 # Switch to using the "fitness" database
19 conn.cursor().execute("USE fitness")
20
21 # Create a "log_in" table to store user login details
22 # Columns:
23 # - cust_name: stores the customer's name
24 # - account_no: stores the account number as an integer
25 # - password: stores the password as an integer
26 conn.cursor().execute('create table log_in(cust_name varchar(65), account_no int, password
int)')
27 print("Log_in table created")
28
29 # Create a "customer_table" to store customer information and payment details
30 # Columns:
31 # - f_name: stores the first name of the customer
32 # - price: stores the payment amount as an integer
33 # - wieght: stores the customer's weight as an integer
34 # - cust_name: stores the customer's name, linked to log_in table
35 # - phone_no: stores the customer's phone number as a bigint
36 conn.cursor().execute('create table customer_table(f_name varchar(65), price int, wieght int,
cust_name varchar(65), phone_no bigint)')
37 print("Customer table created")
38
39 # Commit the changes to the database
40 conn.commit()
41 print("DONE")
42
43
44

localhost:49153/d58c5e25-3a2c-4944-bb97-58e609a25893/ 1/1

You might also like