Пример #1
0
    def continues(self):
        a = str(self.txtid.get())
        b = str(self.txtname.get())
        c = str(self.txtmeter.get())
        d = str(self.txtward.get())
        e = str(self.txthousetax.get())
        f = str(self.txthealthtax.get())
        g = str(self.txtlighttax.get())
        h = str(self.txtwatertax.get())
        i = str(self.txttotal.get())

        database = DBConnect(host='localhost',
                             user='******',
                             password='******',
                             database='etax2019')
        new_user = {
            'idnumber': a,
            'meternumber': c,
            'wardnumber': d,
            'name': b,
            'housetax': e,
            'healthtax': f,
            'lighttax': g,
            'watertax': h,
            'total': i
        }
        database.insert(new_user, 'kalamwadiinfo')
        tkinter.messagebox.showinfo('etax-2019',
                                    'Data was entered successfully')
Пример #2
0
class dbTest(TestCase):
    def setUp(self):
        """
        Prepare for Test
        """
        self.database = DBConnect('travis_credentials.json')

    def tearDown(self):
        """
        Finish Testing
        """
        # Delete all created rows
        self.database.cursor.execute("truncate test")
        self.database.commit()
        # Disconnect from database
        self.database.disconnect()

    def test_insert(self):
        """
        Test inserting information into database
        """
        new_user = {
            'name': 'Emin Mastizada',
            'email': '*****@*****.**',
            'views': 6,
        }
        result = self.database.insert(new_user, 'test')
        self.assertTrue(result["status"],
                        "Insert Failed with message %s" % result["message"])

    def test_commit(self):
        """
        Test committing all users at once
        """
        for user in USERS:
            result = self.database.insert(user, 'test', commit=False)
            self.assertTrue(
                result["status"],
                "Insert Failed with message %s" % result["message"])
        self.database.commit()
        # Now there should be 3 users in table with views=0
        result = self.database.fetch('test',
                                     fields=['count(id)'],
                                     filters={'views': 0})
        self.assertTrue(len(result), "Fetch returned empty results")
        if len(result):
            self.assertTrue(
                'count(id)' in result[0].keys(),
                "Requested field 'count(id)' missing in result keys")
            if 'count(id)' in result[0].keys():
                self.assertEqual(result[0]['count(id)'], 3,
                                 "Number of new users in table should be 3")

    def test_fetch(self):
        """
        Test fetching information from database
        """
        pass
Пример #3
0
class dbTest(TestCase):
    def setUp(self):
        """
        Prepare for Test
        """
        self.database = DBConnect('travis_credentials.json')

    def tearDown(self):
        """
        Finish Testing
        """
        # Delete all created rows
        self.database.cursor.execute("truncate test")
        self.database.commit()
        # Disconnect from database
        self.database.disconnect()

    def test_insert(self):
        """
        Test inserting information into database
        """
        new_user = {
            'name': 'Emin Mastizada',
            'email': '*****@*****.**',
            'views': 6,
        }
        result = self.database.insert(new_user, 'test')
        self.assertTrue(result["status"],
                "Insert Failed with message %s" % result["message"])

    def test_commit(self):
        """
        Test committing all users at once
        """
        for user in USERS:
            result = self.database.insert(user, 'test', commit=False)
            self.assertTrue(result["status"],
                    "Insert Failed with message %s" % result["message"])
        self.database.commit()
        # Now there should be 3 users in table with views=0
        result = self.database.fetch(
                        'test',
                        fields=['count(id)'],
                        filters={'views': 0}
                )
        self.assertTrue(len(result), "Fetch returned empty results")
        if len(result):
            self.assertTrue('count(id)' in result[0].keys(),
                    "Requested field 'count(id)' missing in result keys")
            if 'count(id)' in result[0].keys():
                self.assertEqual(result[0]['count(id)'], 3,
                        "Number of new users in table should be 3")

    def test_fetch(self):
        """
        Test fetching information from database
        """
        pass
Пример #4
0
def insert(type1, ammount1):
    '''
    type1 --> str
    ammount1 --> integer
    '''
    database = DBConnect(host=hostname,
                         user=MYSQLusername,
                         password=MYSQLpass,
                         database=dbname)
    new_user = {'type': type1, 'ammount': ammount1}
    database.insert(new_user, 'Maintainance')
    database.commit()
def insert(year1,month1,day1,type1,ammount1):
    '''
    year1 --> integer
    month1 --> integer
    day1 --> integer
    type1 --> str
    ammount1 --> integer
    '''
    database = DBConnect(host=hostname,user=MYSQLusername,password=MYSQLpass, database=dbname)
    new_user = {'year': year1,'month': month1,'day': day1,'type': type1,'ammount': ammount1}
    database.insert(new_user,'Expences')
    database.commit()
def insert(fname1, lname1, Role1, exp1, salary1, att_today1, att_total1):
    '''
    fname1 --> str
    lname1 --> str
    Role1 --> str
    exp1 --> int
    salary1 --> integer
    att_today1 --> integer
    att_total1 --> integer
    '''
    database = DBConnect(host=hostname,user=MYSQLusername,password=MYSQLpass, database=dbname)
    new_user = {'fname' : fname1, 'lname' : lname1, 'Role' : Role1, 'exp' : exp1,
                'salary' : salary1, 'att_today' : att_today1, 'att_total' : att_total1}
    database.insert(new_user,'workers')
    database.commit()
Пример #7
0
    def submit4(self):
        a=str(self.txt_idnumber.get());
        b=str(self.txt_name.get());
        c=str(self.txt_meternumber.get());
        d=str(self.txt_wardnumber.get());
        e=str(self.txt_house.get());
        f=str(self.txt_health.get());
        g=str(self.txt_light.get());
        h=str(self.txt_water.get());
        i=str(self.txt_total.get());
        j=str(self.txt_reciept.get());
        k=str(self.txt_housepaid.get());
        l=str(self.txt_healthpaid.get());
        m=str(self.txt_lightpaid.get());
        n=str(self.txt_waterpaid.get());
        o=str(self.txt_totalpaid.get());
        v=str(self.txt_village.get());



        localtime=str(time.asctime(time.localtime(time.time())))

        t=int(i)
        u=int(o)
        p=str(t-u)


        database = DBConnect(host='localhost',user='******',password='******',database='etax2019')
        new_user = {'village':v,'idnumber': a,'meternumber': c,'wardnumber': d,'name': b,'housetax': e,'healthtax': f,'lighttax': g,'watertax': h,'total': i,'reciptnumber':j,'housetaxpaid':k,'healthtaxpaid':l,'lighttaxpaid':m,'watertaxpaid':n,'totalpaid':o,'rest':p}
        database.insert(new_user,'updateddata')
        database.commit()

        content1="WARNING   !!!!!! \n\n\n     Hi there is a New request to modify eTAX 2019 database \n Here are details: \n Village Name : "+v+"\n\n"
        content2="\nReciept Number :"+j+"\nName :"+b+"\nID Number :"+a+"\nMeter Number :"+c+"\nWard Number :"+d+"\nHouse Tax :"+e+"\nHealth Tax :"+f+"\nLight Tax :"+g+"\nWater Tax :"+h+"\nTotal Ammount of tax to be paid :"+i+"\nPaid House Tax :"+k+"\nPaid Health Tax :"+l+"\nPaid Light Tax :"+m+"\nPiad Water Tax :"+n+"\nTotal Tax paid  :"+o
        totcontaint=content1+content2 


        mail= smtplib.SMTP('smtp.gmail.com',587)
        mail.ehlo()
        mail.starttls()
        mail.login('*****@*****.**','Pass@123')
        mail.sendmail('*****@*****.**','*****@*****.**',totcontaint)
        mail.close()
        messagebox.showinfo("etax-2019","Data Deleted Successfully")
        root.destroy()
Пример #8
0
class DBTest(TestCase):
    def setUp(self):
        """Prepare for Test."""
        environment = os.environ.get('CI_ENV', "local")
        if environment == "local":
            self.database = DBConnect('test/test_credentials.json')
        elif environment == "Gitlab":
            self.database = DBConnect('test/gitlab_credentials.json')
        elif environment == "Travis":
            self.database = DBConnect('test/travis_credentials.json')

    def tearDown(self):
        """Finish Testing."""
        # Delete all created rows
        self.database.cursor.execute("truncate test")
        self.database.commit()
        # Disconnect from database
        self.database.disconnect()

    def test_insert(self):
        """Test inserting information into database."""
        new_user = {
            'name': 'Emin Mastizada',
            'email': '*****@*****.**',
            'views': 6,
        }
        result = self.database.insert(new_user, 'test')
        self.assertTrue(result["status"],
                        "Insert Failed with message %s" % result["message"])

    def test_commit(self):
        """Test committing all users at once."""
        for user in USERS:
            result = self.database.insert(user, 'test', commit=False)
            self.assertTrue(
                result["status"],
                "Insert Failed with message %s" % result["message"])
        self.database.commit()
        # Now there should be 3 users in table with views=0
        result = self.database.fetch('test',
                                     fields=['count(id)'],
                                     filters={'views': 0})
        self.assertTrue(len(result), "Fetch returned empty results")
        if len(result):
            self.assertTrue(
                'count(id)' in result[0].keys(),
                "Requested field 'count(id)' missing in result keys")
            if 'count(id)' in result[0].keys():
                self.assertEqual(result[0]['count(id)'], 3,
                                 "Number of new users in table should be 3")

    def test_fetch(self):
        """Test fetching information from database."""
        pass

    def test_sum(self):
        """Test value_sum functionality."""
        counter = 1
        for user in USERS[:3]:
            user['views'] = counter
            self.database.insert(user, 'test')
            counter += 1
        sum_result = self.database.value_sum('test', fields=['views'])
        # views = 1 + 2 + 3 = 6
        self.assertEqual(sum_result['views'], 6,
                         "Sum of 3 new users should be 6")
Пример #9
0
    def submit5(self):
        a = str(self.txt_idnumber.get())
        b = str(self.txt_name.get())
        c = str(self.txt_meternumber.get())
        d = str(self.txt_wardnumber.get())
        e = str(self.txt_house.get())
        f = str(self.txt_health.get())
        g = str(self.txt_light.get())
        h = str(self.txt_water.get())
        i = str(self.txt_total.get())
        j = str(self.txt_reciept.get())
        k = str(self.txt_housepaid.get())
        l = str(self.txt_healthpaid.get())
        m = str(self.txt_lightpaid.get())
        n = str(self.txt_waterpaid.get())
        o = str(self.txt_totalpaid.get())
        v = str(self.txt_village.get())

        localtime = str(time.asctime(time.localtime(time.time())))

        t = int(i)
        u = int(o)
        p = str(t - u)

        mydb = mysql.connector.connect(host='localhost',
                                       user='******',
                                       passwd='Pass@123',
                                       database='etax2019')
        mycursor = mydb.cursor()
        query = ("DELETE from updateddata where idnumber = %s" % (a))
        mycursor.execute(query)
        mydb.commit()

        mydb = mysql.connector.connect(host='localhost',
                                       user='******',
                                       passwd='Pass@123',
                                       database='etax2019')
        mycursor = mydb.cursor()
        query = ("DELETE from %s where idnumber = %s" % (v, a))
        mycursor.execute(query)
        mydb.commit()

        database = DBConnect(host='localhost',
                             user='******',
                             password='******',
                             database='etax2019')
        new_user = {
            'village': v,
            'idnumber': a,
            'meternumber': c,
            'wardnumber': d,
            'name': b,
            'housetax': e,
            'healthtax': f,
            'lighttax': g,
            'watertax': h,
            'total': i,
            'reciptnumber': j,
            'housetaxpaid': k,
            'healthtaxpaid': l,
            'lighttaxpaid': m,
            'watertaxpaid': n,
            'totalpaid': o,
            'rest': p
        }
        database.insert(new_user, 'updateddataper')
        mydb.commit()

        database = DBConnect(host='localhost',
                             user='******',
                             password='******',
                             database='etax2019')
        new_user = {
            'idnumber': a,
            'meternumber': c,
            'wardnumber': d,
            'name': b,
            'housetax': e,
            'healthtax': f,
            'lighttax': g,
            'watertax': h,
            'total': i,
            'reciptnumber': j,
            'housetaxpaid': k,
            'healthtaxpaid': l,
            'lighttaxpaid': m,
            'watertaxpaid': n,
            'totalpaid': o,
            'rest': p
        }
        database.insert(new_user, v)
        mydb.commit()

        messagebox.showinfo("etax-2019", "Data Deleted Successfully")
Пример #10
0
class DBTest(TestCase):
    def setUp(self):
        """Prepare for Test."""
        environment = os.environ.get('CI_ENV', "local")
        if environment == "local":
            self.database = DBConnect('test/test_credentials.json')
        elif environment == "Gitlab":
            self.database = DBConnect('test/gitlab_credentials.json')
        elif environment == "Travis":
            self.database = DBConnect('test/travis_credentials.json')

    def tearDown(self):
        """Finish Testing."""
        # Delete all created rows
        self.database.cursor.execute("truncate test")
        self.database.commit()
        # Disconnect from database
        self.database.disconnect()

    def test_insert(self):
        """Test inserting information into database."""
        new_user = {
            'name': 'Emin Mastizada',
            'email': '*****@*****.**',
            'views': 6,
        }
        result = self.database.insert(new_user, 'test')
        self.assertTrue(result["status"], "Insert Failed with message %s" % result["message"])

    def test_commit(self):
        """Test committing all users at once."""
        for user in USERS:
            result = self.database.insert(user, 'test', commit=False)
            self.assertTrue(result["status"], "Insert Failed with message %s" % result["message"])
        self.database.commit()
        # Now there should be 3 users in table with views=0
        result = self.database.fetch(
                        'test',
                        fields=['count(id)'],
                        filters={'views': 0}
                )
        self.assertTrue(len(result), "Fetch returned empty results")
        if len(result):
            self.assertTrue('count(id)' in result[0].keys(), "Requested field 'count(id)' missing in result keys")
            if 'count(id)' in result[0].keys():
                self.assertEqual(result[0]['count(id)'], 3, "Number of new users in table should be 3")

    def test_fetch(self):
        """Test fetching information from database."""
        pass

    def test_sum(self):
        """Test value_sum functionality."""
        counter = 1
        for user in USERS[:3]:
            user['views'] = counter
            self.database.insert(user, 'test')
            counter += 1
        sum_result = self.database.value_sum(
            'test',
            fields=['views']
        )
        # views = 1 + 2 + 3 = 6
        self.assertEqual(
            sum_result['views'], 6, "Sum of 3 new users should be 6"
        )