|
|
|
@@ -1,5 +1,6 @@
|
|
|
|
|
import sqlalchemy
|
|
|
|
|
from sqlalchemy import create_engine, Column, Integer, String, ForeignKey, Float, DateTime
|
|
|
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
|
|
|
from sqlalchemy.orm import declarative_base
|
|
|
|
|
from sqlalchemy.orm import relationship, sessionmaker
|
|
|
|
|
import sys
|
|
|
|
|
from flask import Flask, render_template
|
|
|
|
@@ -69,6 +70,8 @@ class User(Base):
|
|
|
|
|
credentials = Column(String)
|
|
|
|
|
creation_date = Column(DateTime)
|
|
|
|
|
modification_date = Column(DateTime)
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return f"{self.id=} {self.username=} {self.creation_date=} {self.modification_date=}"
|
|
|
|
|
|
|
|
|
|
class RetailerProduct(Base):
|
|
|
|
|
__tablename__ = 'retailer_product'
|
|
|
|
@@ -78,11 +81,24 @@ class RetailerProduct(Base):
|
|
|
|
|
# Create the database tables
|
|
|
|
|
Base.metadata.create_all(engine)
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
|
def homepage():
|
|
|
|
|
# Create a session
|
|
|
|
|
session = Session()
|
|
|
|
|
|
|
|
|
|
# Get all the classes from SQLAlchemy
|
|
|
|
|
classes = Base.__subclasses__()
|
|
|
|
|
|
|
|
|
|
statement = sqlalchemy.select(User)
|
|
|
|
|
users = session.scalars(statement).all()
|
|
|
|
|
|
|
|
|
|
# Render the template with the classes
|
|
|
|
|
return render_template('test3.html', classes=classes, users=users)
|
|
|
|
|
|
|
|
|
|
# Create command-line arguments for the user class
|
|
|
|
|
def main():
|
|
|
|
|
if len(sys.argv) < 2:
|
|
|
|
|
print("Usage: python user_tool.py [create|edit|delete]")
|
|
|
|
|
return
|
|
|
|
|
app.run()
|
|
|
|
|
|
|
|
|
|
command = sys.argv[1]
|
|
|
|
|
|
|
|
|
@@ -143,21 +159,8 @@ def main():
|
|
|
|
|
print("User not found.")
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
print("Invalid command.")
|
|
|
|
|
print("Usage: python user_tool.py [create|edit|delete]")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
|
def homepage():
|
|
|
|
|
# Create a session
|
|
|
|
|
session = Session()
|
|
|
|
|
|
|
|
|
|
# Get all the classes from SQLAlchemy
|
|
|
|
|
classes = Base.__subclasses__()
|
|
|
|
|
|
|
|
|
|
# Render the template with the classes
|
|
|
|
|
return render_template('test3.html', classes=classes)
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
app.run()
|