Python - CTR class does not register in DB

0

Good evening.

Application developed in Python 3.x Database: sqlalchemy. I'm trying to develop a simple product registration system in a SQL database. For that, I am trying to develop from the MVC Standard (Model, View and Controller). In that sense, I created the classes the way I thought they were correct (according to project file). The problem is occurring within the ProductCTR class.

'' 'ProductsDAO' '' from DataBase.database importDB Connection from DataBase.database import Tables

class ProductsDAO:

def prod_Cadastrar(produto):
    # Conexão
    conexaoDB = ConexaoDB()
    db = conexaoDB.db()
    meta = conexaoDB.meta()

    # Tabelas
    table = Tabelas()
    prodTable = table.prod_Table()

    # Inserir no DB
    db.excute(prodTable.insert(), [{'prod_Desc': produto.prod_Desc,
                                    'prod_Unid': produto.prod_Unid,
                                    'prod_VrUnit': produto.prod_VrUnit}])

** Controller module **

from Model.DTO.produtosDTO import ProdutosDTO
from Model.DAO.produtosDAO import ProdutosDAO


class ProdutosCTR:

    def prod_Cadastrar(self, prod_Desc, prod_Unid, prod_VrUnit):
        produtoDTO = ProdutosDTO()
        produtoDTO.prod_Desc = prod_Desc
        produtoDTO.prod_Unid = prod_Unid
        produtoDTO.prod_VrUnit = prod_VrUnit

        produtoDAO = ProdutosDAO()
        produtoDAO.prod_Cadastrar(produtoDTO)

As you can see, in this class the prod_Count () function of the productDAO object receives the productDTO, whose attributes were filled in the interface:

** Interface **

from Controller.produtosCTR import ProdutosCTR


class Interface:

    def prod_Cadastrar(self):
        prodCTR = ProdutosCTR()
        desc = self.prod_CadDesc()
        unid = self.prod_CadUnid()
        vr_unit = self.prod_CadVrUnit()
        prodCTR.prod_Cadastrar(desc, unid, vr_unit)

    def prod_CadDesc(self):
        self.descricao = str(input('Descrição: ')).upper()
        return self.descricao

    def prod_CadUnid(self):
        self.unid = str(input('Unidade: ')).upper()
        return self.unid

    def prod_CadVrUnit(self):
        self.valorUnit = float(input('Valor Unitário: '))
        return self.valorUnit

When you try to run the code the following error appears:

  

"C: \ Users \ theu_ \ PycharmProjects \ Melon v.   0.0.1 \ venv \ Scripts \ python.exe "" C: / Users / theu_ / PycharmProjects / Melon v. 0.0.1 / main.py "Description: Matheus Unit: kg Unit Value: 10   Traceback (most recent call last): File   "C: / Users / theu_ / PycharmProjects / Melon v. 0.0.1 / main.py", line 7, in          int.prod_Count () File "C: \ Users \ theu_ \ PycharmProjects \ Melon v. 0.0.1 \ View \ interface.py", line 14, in prod_Count       prodCTR.prod_Count (desc, unid, vr_unit) File "C: \ Users \ theu_ \ PycharmProjects \ Melon v.   0.0.1 \ Controller \ productsCTR.py ", line 18, in prod_Count       productDATA.prod_Count (productDTO)    TypeError: prod_Count () takes 1 positional argument but 2 was given

     

Process finished with exit code 1

Can anyone help me understand the problem? Thank you very much.

    
asked by anonymous 01.02.2018 / 23:27

0 answers