backend/__db_management__/create_products.py
def create_sql_file(cls):
        """
        This method created a set of sql commands in order to populate the database. The data was mocked by:
        -> https://www.mockaroo.com/
        """

        # Checking if the sql file exists
        cls.check_sql_file()

        # Eliminating repeated products
        cls.treat_data()

        # Script Generation
        with open(file=cls.data, mode="r", encoding="utf-8") as data:
            with open(file=cls.sql_file, mode="w", encoding="utf-8") as sql:
                data = DictReader(f=data, fieldnames=cls.headers)
                next(data)

                for row in data:
                    row[cls.headers[5]] = 1 if row.get(cls.headers[5]) == "true" else 0
                    statement = f"""INSERT INTO PRODUCTS (
                        name, unity_price, suppliers_percentage, freight_percentage, amount_in_stock, is_active, created_at,
                        updated_at, description) VALUES (
                        '{row.get(cls.headers[0])}',
                        '{row.get(cls.headers[1])}',
                        '{row.get(cls.headers[2])}',
                        '{row.get(cls.headers[3])}',
                        '{row.get(cls.headers[4])}',
                        '{row.get(cls.headers[5])}',
                        '{row.get(cls.headers[6])}',
                        '{row.get(cls.headers[6])}',
                        '');\n"""
                    sql.write(statement)

        This method created a set of sql commands in order to populate the database. The data was mocked by:
        -> https://www.mockaroo.com/
        
This method created a set of sql commands in order to populate the database.
This method created a set of sql commands in order to populate the database .
def create_sql_file(cls):
        cls.check_sql_file()
        cls.treat_data()
        with open(file=cls.data, mode="r", encoding="utf-8") as data:
            with open(file=cls.sql_file, mode="w", encoding="utf-8") as sql:
                data = DictReader(f=data, fieldnames=cls.headers)
                next(data)
                for row in data:
                    row[cls.headers[5]] = 1 if row.get(cls.headers[5]) == "true" else 0
                    statement = f"""INSERT INTO PRODUCTS (
                        name, unity_price, suppliers_percentage, freight_percentage, amount_in_stock, is_active, created_at,
                        updated_at, description) VALUES (
                        '{row.get(cls.headers[0])}',
                        '{row.get(cls.headers[1])}',
                        '{row.get(cls.headers[2])}',
                        '{row.get(cls.headers[3])}',
                        '{row.get(cls.headers[4])}',
                        '{row.get(cls.headers[5])}',
                        '{row.get(cls.headers[6])}',
                        '{row.get(cls.headers[6])}',
                        '');\n"""
                    sql.write(statement)
def create_sql_file ( cls ) : cls . check_sql_file ( ) cls . treat_data ( ) with open ( file = cls . data , mode = "r" , encoding = "utf-8" ) as data : with open ( file = cls . sql_file , mode = "w" , encoding = "utf-8" ) as sql : data = DictReader ( f = data , fieldnames = cls . headers ) next ( data ) for row in data : row [ cls . headers [ 5 ] ] = 1 if row . get ( cls . headers [ 5 ] ) == "true" else 0 statement = f"""INSERT INTO PRODUCTS (
                        name, unity_price, suppliers_percentage, freight_percentage, amount_in_stock, is_active, created_at,
                        updated_at, description) VALUES (
                        '{row.get(cls.headers[0])}',
                        '{row.get(cls.headers[1])}',
                        '{row.get(cls.headers[2])}',
                        '{row.get(cls.headers[3])}',
                        '{row.get(cls.headers[4])}',
                        '{row.get(cls.headers[5])}',
                        '{row.get(cls.headers[6])}',
                        '{row.get(cls.headers[6])}',
                        '');\n""" sql . write ( statement )
This method created a set of sql commands in order to populate the database.
This method created a set of sql commands in order to populate the database .
"""
        This method created a set of sql commands in order to populate the database. The data was mocked by:
        -> https://www.mockaroo.com/
        """ # Checking if the sql file exists # Eliminating repeated products # Script Generation
cls