From 0b37d944bbd058770af70898c09f639c2dc92e7a Mon Sep 17 00:00:00 2001 From: spla Date: Mon, 26 Jul 2021 15:43:02 +0200 Subject: [PATCH] Added register reason --- db-setup.py | 2 +- spamcheck.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/db-setup.py b/db-setup.py index 01cc98c..f96ca6e 100644 --- a/db-setup.py +++ b/db-setup.py @@ -150,7 +150,7 @@ if __name__ == '__main__': db_user = spamcheck_db_user table = "spamcheck" - sql = "create table "+table+" (created_at timestamptz, id bigint PRIMARY KEY, email varchar(200), ip inet)" + sql = "create table "+table+" (created_at timestamptz, id bigint PRIMARY KEY, email varchar(200), ip inet, text varchar(200))" create_table(db, db_user, table, sql) ############################################################ diff --git a/spamcheck.py b/spamcheck.py index 0c5fc0a..60c8bda 100644 --- a/spamcheck.py +++ b/spamcheck.py @@ -55,6 +55,8 @@ if __name__ == '__main__': email_lst = [] ip_lst = [] + + text_lst = [] try: @@ -64,7 +66,7 @@ if __name__ == '__main__': cur = conn.cursor() - cur.execute("select created_at, id, email, sign_up_ip from users where not approved;") + cur.execute("select users.created_at, users.id, users.email, users.sign_up_ip, user_invite_requests.text from users, user_invite_requests where not users.approved and users.id = user_invite_requests.user_id") rows = cur.fetchall() @@ -80,6 +82,8 @@ if __name__ == '__main__': ip_lst.append(row[3]) + text_lst.append(row[4]) + cur.close() except (Exception, psycopg2.DatabaseError) as error: @@ -94,7 +98,7 @@ if __name__ == '__main__': ############################################################################### - insert_sql = 'INSERT INTO spamcheck(created_at, id, email, ip) VALUES(%s,%s,%s,%s) ON CONFLICT DO NOTHING' + insert_sql = 'INSERT INTO spamcheck(created_at, id, email, ip, text) VALUES(%s,%s,%s,%s,%s) ON CONFLICT DO NOTHING' i = 0 @@ -108,7 +112,7 @@ if __name__ == '__main__': cur = conn.cursor() - cur.execute(insert_sql, (created_at_lst[i], id_lst[i], email_lst[i], ip_lst[i])) + cur.execute(insert_sql, (created_at_lst[i], id_lst[i], email_lst[i], ip_lst[i], text_lst[i])) conn.commit() @@ -124,7 +128,7 @@ if __name__ == '__main__': conn.close() - print(created_at_lst[i], id_lst[i], email_lst[i], ip_lst[i]) + print(created_at_lst[i], id_lst[i], email_lst[i], ip_lst[i], text_lst[i]) i = i + 1