[main] Testing in app.py
This commit is contained in:
parent
427cd25853
commit
75550c7f6f
69
src/app.py
69
src/app.py
@ -1,56 +1,39 @@
|
|||||||
# import sys
|
import sys
|
||||||
# from PySide6.QtGui import QGuiApplication
|
from PySide6 import QtWidgets, QtCore
|
||||||
# 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)
|
|
||||||
|
|
||||||
|
|
||||||
from sqlalchemy import create_engine
|
from ui.dashboard import LibraryDashboard
|
||||||
from sqlalchemy.orm import sessionmaker
|
|
||||||
|
|
||||||
from models.book import Book, BookStatusEnum
|
|
||||||
from models.author import Author
|
|
||||||
|
|
||||||
# Replace with your MySQL database credentials
|
if __name__ == "__main__":
|
||||||
DATABASE_URI = 'mysql+mysqlconnector://username:password@localhost:3306/library'
|
app = QtWidgets.QApplication([])
|
||||||
|
window = LibraryDashboard()
|
||||||
|
window.show()
|
||||||
|
sys.exit(app.exec())
|
||||||
|
|
||||||
# Create the engine
|
# from sqlalchemy import create_engine
|
||||||
engine = create_engine(DATABASE_URI, echo=True)
|
# from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
# Create a configured session class
|
# from models.book import Book, BookStatusEnum
|
||||||
SessionLocal = sessionmaker(bind=engine)
|
# from models.author import Author
|
||||||
|
|
||||||
# Create a session instance
|
# # Replace with your MySQL database credentials
|
||||||
session = SessionLocal()
|
# 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)
|
# from models.base import Base
|
||||||
session.commit()
|
# Base.metadata.create_all(engine)
|
||||||
|
|
||||||
new_book = Book(
|
# # Create a configured session class
|
||||||
title="Sample Book",
|
# SessionLocal = sessionmaker(bind=engine)
|
||||||
description="A fascinating tale.",
|
|
||||||
year_published="2023",
|
|
||||||
isbn="1234567890123",
|
|
||||||
status='available',
|
|
||||||
author_id=new_author.id
|
|
||||||
)
|
|
||||||
|
|
||||||
session.add(new_book)
|
# # Create a session instance
|
||||||
session.commit()
|
# session = SessionLocal()
|
||||||
|
|
||||||
books = session.query(Book).all()
|
# books = session.query(Book).all()
|
||||||
for book in books:
|
# for book in books:
|
||||||
print(book.title, book.author.first_name)
|
# print(book.title, book.author.first_name)
|
||||||
|
|
||||||
session.close()
|
# session.close()
|
Loading…
x
Reference in New Issue
Block a user