| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 | import pathlibcurrent = pathlib.Path(__file__).parentroot = current.parentimport syssys.path.append(str(root))import assetsimport sqlmodeldef drop_database() -> None:    db = pathlib.Path("./003-product_app.db")    if db.is_file():        db.unlink()drop_database()connection = sqlmodel.create_engine("sqlite:///003-product_app.db")sqlmodel.SQLModel.metadata.create_all(connection)users = assets.users_collection()factory = assets.user_factory()factory.nick = "test"factory.password = "12345678"users.add(factory.result)app = assets.product_app(connection, users)print("App initialized.")create = app.create({    "barcode": "123456789012",    "name": "Sample",    "description": "This is sample name.",    "author": "John Snow",    "image": "https://uuu.owo.pl",    "stock_count": "10",    "apikey": factory.apikey})print("Create:")print(create)print()select = app.get_barcode("123456789012")print("Select by barcode:")print(select)print()select = app.get_name("Sample")print("Select by name:")print(select)print()create = app.create({    "barcode": "210987654321",    "name": "Second sample",    "description": "This is sample item second.",    "author": "other",    "image": "https://test.pl",    "stock_count": "20",    "apikey": factory.apikey})print("Create second:")print(create)print()alls = app.all()print("Select all:")print(alls)print()modify = app.update({    "barcode": "210987654321",    "target_barcode": "210987654321",    "name": "Second sample",    "description": "This is sample item second.",    "author": "other",    "image": "https://test.pl",    "stock_count": "20",    "apikey": factory.apikey})print("Modify:")print(modify)print()drop_database()
 |