diff --git a/db.py b/db.py index c9bd880..366e114 100644 --- a/db.py +++ b/db.py @@ -33,7 +33,7 @@ class User(Base): class Product(Base): __tablename__ = 'products' - bar_code = Column(Integer, primary_key=True) + bar_code = Column(String(13), primary_key=True) name = Column(String(30)) price = Column(Integer) diff --git a/text_based.py b/text_based.py index f32126d..c8fbcf5 100644 --- a/text_based.py +++ b/text_based.py @@ -360,7 +360,7 @@ class AddProductMenu(Menu): def _execute(self): self.session = Session() self.print_header() - bar_code = self.input_int('Bar code> ') + bar_code = self.input_str('Bar code> ', Product.bar_code_re, (8,13)) name = self.input_str('Name> ', Product.name_re, (1,30)) price = self.input_int('Price> ', (1,100000)) product = Product(bar_code, name, price)