28 lines
815 B
Python
28 lines
815 B
Python
|
|
import streamlit as st
|
||
|
|
import mysql.connector
|
||
|
|
from mysql.connector import errorcode
|
||
|
|
import pandas as pd
|
||
|
|
|
||
|
|
try:
|
||
|
|
conn = mysql.connector.connect(user='root',password='Throwaway', host='localhost',port=3306,database='workouts')
|
||
|
|
except mysql.connector.Error as err:
|
||
|
|
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
|
||
|
|
print("Something is wrong with your user name or password")
|
||
|
|
elif err.errno == errorcode.ER_BAD_DB_ERROR:
|
||
|
|
print("Database does not exist")
|
||
|
|
else:
|
||
|
|
print(err)
|
||
|
|
else:
|
||
|
|
cursor = conn.cursor()
|
||
|
|
query = ("SELECT * FROM `workouts`")
|
||
|
|
cursor.execute(query)
|
||
|
|
data = cursor.fetchall()
|
||
|
|
df = pd.DataFrame(data,columns=cursor.column_names)
|
||
|
|
conn.commit()
|
||
|
|
cursor.close()
|
||
|
|
conn.close()
|
||
|
|
|
||
|
|
# Streamlit Entry Form
|
||
|
|
st.title('Workouts Database')
|
||
|
|
|
||
|
|
st.dataframe(df)
|