Download pp.py from Pezh/Too: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/spaces/Pezh/Too/resolve/main/pp.py
- Command line
-
hf download hf://spaces/Pezh/Too/pp.py
-
curl -L -o pp.py https://huggingface.co/spaces/Pezh/Too/resolve/main/pp.py
1.37 kB
| import streamlit as st | |
| import time | |
| import datetime | |
| from sqlalchemy import create_engine | |
| import pandas as pd | |
| from sqlalchemy import create_engine, MetaData, Table, Column, Integer, DateTime | |
| # Database connection | |
| engine = create_engine('sqlite:///date_time.db') | |
| # Define a table object using SQLAlchemy's Table construct | |
| metadata = MetaData() | |
| date_table = Table( | |
| 'date_table', metadata, | |
| Column('id', Integer, primary_key=True), | |
| Column('date_time', DateTime) | |
| ) | |
| # Create the table in the database | |
| metadata.create_all(engine) | |
| # Database connection | |
| #engine = create_engine('sqlite:///date_time.db') | |
| # Create a table in the database to store the date and time | |
| #with engine.connect() as con: | |
| #con.execute('CREATE TABLE IF NOT EXISTS date_table (id INTEGER PRIMARY KEY, date_time TIMESTAMP)') | |
| # Function to save date and time to the database | |
| def save_to_database(): | |
| with engine.connect() as con: | |
| con.execute("INSERT INTO date_table (date_time) VALUES (?)", datetime.datetime.now()) | |
| # Streamlit app | |
| st.title('Date and Time Saver') | |
| # Button to start the loop | |
| start_button = st.button('Save Date and Time') | |
| # Loop to save the date and time to the database every 2 minutes | |
| if start_button: | |
| st.write('Saving date and time every 2 minutes...') | |
| while start_button: | |
| save_to_database() | |
| time.sleep(120) # Sleep for 2 minutes |