Cleanb up data insert

This commit is contained in:
CHIEFSOFT\ameye
2025-01-08 20:11:00 -05:00
parent 787e4c6f9e
commit 3f2fa6efc7
+65 -21
View File
@@ -104,22 +104,39 @@ engine = create_engine(dataUrl)
@app.route("/") @app.route("/")
def hello_world(): def hello_world():
# mail.send( email="ameye+" + str( random.randint(1000, 99999)) + "@chiefsoft.com"
# subject="Template example", firstname="First" + str(random.randint(10, 100))
# receivers=["ameye@chiefsoft.com"], lastname="Last" + str(random.randint(10, 100));
# html_template="email/verify.html"
# )
send_register_mail('ameye@chiefsoft.com') SELECT_INSERT = "SELECT uid, firstname , lastname , email FROM members_pending WHERE status = 0 AND email='" + email + "'"
# msg = Message( print(SELECT_INSERT)
# 'Hello', ADJUST_PREVIOUS = "UPDATE members_pending SET status = 3 WHERE status = 0 AND email='" + email + "'"
# sender ='message@chiefsoft.com', val_update = (email)
# recipients = ['ses66181@gmail.com'] val_insert = (email, firstname, lastname)
# ) INSERT_MEMBERS = "INSERT INTO members_pending(email,firstname,lastname) VALUES(%s,%s,%s)"
# msg.body = 'Hello Flask message sent from Flask-Mail' with connection:
# mail.send(msg) with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
cursor.execute(ADJUST_PREVIOUS)
cursor.execute(INSERT_MEMBERS, val_insert)
# connection.commit()
# last_row_id=cursor.lastrowid
# print('After Insert ::: ')
# #connection.insert_id()
# print(last_row_id)
return jsonify(action_data="sent") SELECT_INSERT = "SELECT uid, firstname , lastname , email FROM members_pending WHERE status = 0 AND email='" + email + "'"
print(SELECT_INSERT)
with connection:
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
cursor.execute(SELECT_INSERT)
select_pendingRes = cursor.fetchall()
print(select_pendingRes)
select_pending = json.dumps( [dict(ix) for ix in select_pendingRes] )
print(select_pending)
array3 = json.loads(select_pending)
return jsonify(action_data="sent", select_pending=array3)
@app.route("/test/products") @app.route("/test/products")
@@ -272,17 +289,44 @@ def start_register():
# values = ("john", "password123") # values = ("john", "password123")
# cursor.execute(query, values) # cursor.execute(query, values)
# conn.commit() # conn.commit()
# email="ameye+" + str( random.randint(1000, 99999)) + "@chiefsoft.com"
# firstname="First" + str(random.randint(10, 100))
# lastname="Last" + str(random.randint(10, 100));
INSERT_MEMBERS = "INSERT INTO members_pending(email,firstname,lastname) VALUES('"+email+"','"+firstname+"','"+lastname+"')" SELECT_INSERT = "SELECT id,uid, firstname , lastname , email FROM members_pending WHERE status = 0 AND email='" + email + "'"
print(SELECT_INSERT)
ADJUST_PREVIOUS = "UPDATE members_pending SET status = 3 WHERE status = 0 AND email='" + email + "'"
val_update = (email)
val_insert = (email, firstname, lastname)
INSERT_MEMBERS = "INSERT INTO members_pending(email,firstname,lastname) VALUES(%s,%s,%s)"
with connection: with connection:
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor: with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
cursor.execute(INSERT_MEMBERS) cursor.execute(ADJUST_PREVIOUS)
connection.commit() cursor.execute(INSERT_MEMBERS, val_insert)
last_row_id=cursor.lastrowid
print('After Insert ::: ')
print(last_row_id)
send_register_mail(email) print(SELECT_INSERT)
with connection:
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
cursor.execute(SELECT_INSERT)
select_pendingRes = cursor.fetchall()
print(select_pendingRes)
select_pending = json.dumps( [dict(ix) for ix in select_pendingRes] )
print(select_pending)
array3 = json.loads(select_pending)
last_row_id = array3[last_row_id]
# INSERT_MEMBERS = "INSERT INTO members_pending(email,firstname,lastname) VALUES('"+email+"','"+firstname+"','"+lastname+"')"
# with connection:
# with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
# cursor.execute(INSERT_MEMBERS)
# connection.commit()
# last_row_id=cursor.lastrowid
# print('After Insert ::: ')
# print(last_row_id)
send_register_mail(email)
return jsonify(hello="ameye signup path world", last_row_id=last_row_id) return jsonify(hello="ameye signup path world", last_row_id=last_row_id)
except Exception as e: except Exception as e: