示例#1
0
    def insert_random_seller(self, repeat=qsellers):
        ''' Inserir registros com valores randomicos '''

        seller_list = []
        for _ in range(repeat):
            d = gen_timestamp(2014, 2015) + '+00'
            fname = names.get_first_name()
            lname = names.get_last_name()
            email = fname[0].lower() + '.' + lname.lower() + '@example.com'
            birthday = gen_timestamp() + '+00'
            active = rstr.rstr('01', 1)
            internal = rstr.rstr('01', 1)
            commissioned = rstr.rstr('01', 1)
            commission = 0.01
            seller_list.append(
                (gen_cpf(), fname, lname, email, gen_phone(), birthday, active, internal, commissioned, commission, d, d))
        try:
            self.db.cursor.executemany("""
            INSERT INTO vendas_seller (cpf, firstname, lastname, email, phone, birthday, active, internal, commissioned, commission, created, modified)
            VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
            """, seller_list)
            self.db.commit_db()
            print("Inserindo %s registros na tabela vendas_seller." % repeat)
            print("Registros criados com sucesso.")
        except sqlite3.IntegrityError:
            print("Aviso: O email deve ser único.")
            return False
示例#2
0
    def insert_random_customer(self, repeat=qcustomers):
        ''' Inserir registros com valores randomicos '''

        customer_list = []
        for _ in range(repeat):
            # d = datetime.datetime.now().isoformat(" ")
            d = gen_timestamp(2014, 2015) + '+00'
            fname = names.get_first_name()
            lname = names.get_last_name()
            email = fname[0].lower() + '.' + lname.lower() + '@example.com'
            birthday = gen_timestamp() + '+00'
            customer_list.append(
                (gen_cpf(), fname, lname, email, gen_phone(), birthday, d, d))
        try:
            self.db.cursor.executemany("""
            INSERT INTO vendas_customer (cpf, firstname, lastname, email, phone, birthday, created, modified)
            VALUES (?,?,?,?,?,?,?,?)
            """, customer_list)
            self.db.commit_db()
            print("Inserindo %s registros na tabela vendas_customer." % repeat)
            print("Registros criados com sucesso.")
        except sqlite3.IntegrityError:
            print("Aviso: O email deve ser único.")
            return False
示例#3
0
    def insert_random_sale(self, repeat=qsales):

        sale_list = []
        for _ in range(repeat):
            d = gen_timestamp(2014, 2015) + '+00'
            customer = random.randint(1, qcustomers)
            seller = random.randint(1, qsellers)
            sale_list.append((customer, seller, d, d))
        try:
            self.db.cursor.executemany("""
            INSERT INTO vendas_sale (customer_id, seller_id, date_sale, modified)
            VALUES (?,?,?,?)
            """, sale_list)
            self.db.commit_db()
            print("Inserindo %s registros na tabela vendas_sale." % repeat)
            print("Registros criados com sucesso.")
        except sqlite3.IntegrityError:
            return False