-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathload_trans.py
More file actions
51 lines (51 loc) · 990 Bytes
/
load_trans.py
File metadata and controls
51 lines (51 loc) · 990 Bytes
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
45
46
47
48
49
50
51
import sqlite3
import json
import sys
a=''
lst=[]
s=1
r=0
k=0
D = {}
db=sqlite3.connect('details')
cur=db.cursor()
name=""
cur.execute('SELECT trans from investor where id = ?',(str(sys.argv[1]),))
ab=cur.fetchone()
ab = ab[0].split(',')
for i in ab:
a = ''
cur.execute('SELECT id, cid, uid, amt, share, datee from transac where id = ?',(i,))
data = cur.fetchone()
cid = data[1]
uid = data[2]
cur.execute('SELECT name FROM company WHERE id = ?', (cid,))
c_name = str(cur.fetchone()[0])
cur.execute('SELECT uname FROM investor WHERE id = ?', (uid,))
u_name = str(cur.fetchone()[0])
r=0
for t in data:
if r==1:
a+=str(c_name)
r+=1
a+='#'
continue
if r==2:
a+=str(u_name)
a+='#'
r+=1
continue
r+=1
a+=str(t)
a+='#'
comp = str(data[1])
share = float(data[4])
cur.execute('SELECT profit from company where id = ?', (comp))
prof = int(cur.fetchone()[0])
ret = prof*share*0.01
a+=str(ret)
a+='#'
D[k] = a
k+=1
print (json.dumps(D))
sys.exit()