[main] Added model for a view

This commit is contained in:
Thastertyn 2025-01-07 21:24:49 +01:00
parent fb7aebd0d7
commit 277abe79d7
3 changed files with 24 additions and 7 deletions

View File

@ -2,20 +2,19 @@ import sys
from PySide6 import QtWidgets, QtCore
from ui.dashboard import LibraryDashboard
from ui.window import LibraryWindow
if __name__ == "__main__":
app = QtWidgets.QApplication([])
window = LibraryDashboard()
window = LibraryWindow()
window.show()
sys.exit(app.exec())
# from sqlalchemy import create_engine
# from sqlalchemy.orm import sessionmaker
# from models.book import Book, BookStatusEnum
# from models.author import Author
# from models.book_overview_view import BookOverviewView
# # Replace with your MySQL database credentials
# DATABASE_URI = 'mysql+mysqlconnector://username:password@localhost:3306/library'
@ -32,8 +31,8 @@ if __name__ == "__main__":
# # Create a session instance
# session = SessionLocal()
# books = session.query(Book).all()
# books = session.query(BookOverviewView).all()
# for book in books:
# print(book.title, book.author.first_name)
# print(book.title, book.author_name, book.categories)
# session.close()

View File

@ -7,4 +7,6 @@ from .member import Member
from .librarian import Librarian
from .loan import Loan
__all__ = ["Author", "Book", "BookCategory", "BookCategoryLink", "Member", "Librarian", "Loan"]
from .book_overview_view import BookOverviewView
__all__ = ["Author", "Book", "BookCategory", "BookCategoryLink", "Member", "Librarian", "Loan", "BookOverviewView"]

View File

@ -0,0 +1,16 @@
from sqlalchemy import Column, String, TIMESTAMP, Integer
from .base import Base
class BookOverviewView(Base):
__tablename__ = 'books_overview'
id = Column(Integer, primary_key=True, autoincrement=True)
title = Column(String())
author_name = Column(String())
categories = Column(String())
year_published = Column(String())
isbn = Column(String())
created_at = Column(TIMESTAMP())
borrower_name = Column(String())
librarian_name = Column(String())