Fix Data
This commit is contained in:
+35
-1
@@ -144,7 +144,7 @@ def salary_demousers():
|
||||
dList = []
|
||||
|
||||
|
||||
SELECT_DEMO_ENTRY = f"SELECT id,uid, bvn AS CustomerID, mobile AS AccountID, name,offers,salary_account,current_loans,mobile,bvn, email, pin, added::text, balance, updated::text AS updated FROM demo_bank_accounts ORDER BY id ASC"
|
||||
SELECT_DEMO_ENTRY = f"SELECT id,uid, bvn AS CustomerID, mobile AS AccountID, name,offers,salary_account,current_loans,mobile,bvn, email, pin, added::text, balance, updated::text AS updated FROM demo_bank_accounts ORDER BY id DESC LIMIT 1500"
|
||||
# print(SELECT_DEMO_ENTRY)
|
||||
with connection:
|
||||
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
|
||||
@@ -639,6 +639,9 @@ def repay_loans():
|
||||
|
||||
@app.route('/simulation/generator')
|
||||
def generate_activities():
|
||||
|
||||
# insert_random_users()
|
||||
|
||||
generate_simulation_salary()
|
||||
|
||||
generate_simulation_transaction()
|
||||
@@ -647,6 +650,37 @@ def generate_activities():
|
||||
|
||||
return []
|
||||
|
||||
def insert_random_users():
|
||||
SQL_ACC = "SELECT accountid AS account_no FROM trx_raw GROUP BY accountid"
|
||||
with connection:
|
||||
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
|
||||
cursor.execute(SQL_ACC)
|
||||
select_demoS = cursor.fetchall()
|
||||
|
||||
loan_data = json.dumps( [dict(ix) for ix in select_demoS] )
|
||||
accounts_result = json.loads( loan_data)
|
||||
SQL_INSERT = "INSERT INTO demo_bank_accounts (name, salary_account, mobile, bvn, email, pin) VALUES(%s,%s,%s,%s,%s,%s)"
|
||||
# Iterate through the JSON array
|
||||
for item in accounts_result:
|
||||
accountNo = item["account_no"]
|
||||
new_data = (
|
||||
names.get_full_name() ,
|
||||
random.randint(0, 1),
|
||||
'811-'+str( random.randint(100, 999) )+'-'+str( random.randint(1000, 9999) ) ,
|
||||
accountNo,
|
||||
'demo+'+ names.get_first_name() +'@chiefsoft.net',
|
||||
random.randint(1100, 9999)
|
||||
)
|
||||
|
||||
print(new_data)
|
||||
with connection:
|
||||
try:
|
||||
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
|
||||
cursor.execute(SQL_INSERT, new_data)
|
||||
except Exception as e:
|
||||
print(0)
|
||||
|
||||
|
||||
def generate_simulation_salary():
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user