From 75550c7f6f3e29af26634ea14f8222b6d1551e73 Mon Sep 17 00:00:00 2001 From: Thastertyn Date: Tue, 7 Jan 2025 15:25:47 +0100 Subject: [PATCH] [main] Testing in app.py --- src/app.py | 69 ++++++++++++++++++++---------------------------------- 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/src/app.py b/src/app.py index f553d0e..4217b93 100644 --- a/src/app.py +++ b/src/app.py @@ -1,56 +1,39 @@ -# import sys -# from PySide6.QtGui import QGuiApplication -# from PySide6.QtQml import QQmlApplicationEngine - -# if __name__ == "__main__": -# app = QGuiApplication(sys.argv) -# engine = QQmlApplicationEngine() -# engine.addImportPath(sys.path[0]) -# engine.loadFromModule("ui", "Main") -# if not engine.rootObjects(): -# sys.exit(-1) -# exit_code = app.exec() -# del engine -# sys.exit(exit_code) +import sys +from PySide6 import QtWidgets, QtCore -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker +from ui.dashboard import LibraryDashboard -from models.book import Book, BookStatusEnum -from models.author import Author -# Replace with your MySQL database credentials -DATABASE_URI = 'mysql+mysqlconnector://username:password@localhost:3306/library' +if __name__ == "__main__": + app = QtWidgets.QApplication([]) + window = LibraryDashboard() + window.show() + sys.exit(app.exec()) -# Create the engine -engine = create_engine(DATABASE_URI, echo=True) +# from sqlalchemy import create_engine +# from sqlalchemy.orm import sessionmaker -# Create a configured session class -SessionLocal = sessionmaker(bind=engine) +# from models.book import Book, BookStatusEnum +# from models.author import Author -# Create a session instance -session = SessionLocal() +# # Replace with your MySQL database credentials +# DATABASE_URI = 'mysql+mysqlconnector://username:password@localhost:3306/library' -new_author = Author(first_name="John", last_name="Doe") +# # Create the engine +# engine = create_engine(DATABASE_URI) -session.add(new_author) -session.commit() +# from models.base import Base +# Base.metadata.create_all(engine) -new_book = Book( - title="Sample Book", - description="A fascinating tale.", - year_published="2023", - isbn="1234567890123", - status='available', - author_id=new_author.id -) +# # Create a configured session class +# SessionLocal = sessionmaker(bind=engine) -session.add(new_book) -session.commit() +# # Create a session instance +# session = SessionLocal() -books = session.query(Book).all() -for book in books: - print(book.title, book.author.first_name) +# books = session.query(Book).all() +# for book in books: +# print(book.title, book.author.first_name) -session.close() \ No newline at end of file +# session.close() \ No newline at end of file