-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert_data.py
More file actions
44 lines (37 loc) · 1.06 KB
/
insert_data.py
File metadata and controls
44 lines (37 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import mysql.connector as con
mycon=con.connect(host="localhost",user="*****",passwd="******",database="Expense_manager")
mycur=mycon.cursor()
class insert_data():
"""docstring for insert_data"""
def __init__(self, arg):
super(insert_data, self).__init__()
self.arg = arg
def insert_e(id,type,amount,date,desc):
val=[]
val.append(id)
val.append(type)
val.append(amount)
val.append(date)
val.append(desc)
print("values im going to insert ************",str(val))
sql="INSERT INTO expense VALUES(%s,%s,%s,%s,%s)"
mycur.execute(sql,val)
mycon.commit()
print("Commited")
sql="SELECT type , sum(amount) as t FROM expense where id='2017135040' group by type "
mycur.execute(sql)
record=mycur.fetchall()
print("after commited:-"+str(record))
return 1
print("returned but still here")
def insert_i(id,type,amount,date,desc):
val=[]
val.append(id)
val.append(type)
val.append(amount)
val.append(date)
val.append(desc)
sql="INSERT INTO income VALUES(%s,%s,%s,%s,%s)"
mycur.execute(sql,val)
mycon.commit()
print("Commited")