diff --git a/mastotuit.py b/mastotuit.py index 2a5e41a..5160843 100644 --- a/mastotuit.py +++ b/mastotuit.py @@ -231,7 +231,7 @@ if __name__ == '__main__': try: conn = None - + conn = psycopg2.connect(database = feeds_db, user = feeds_db_user, password = "", host = "/var/run/postgresql", port = "5432") cur = conn.cursor() @@ -359,7 +359,9 @@ if __name__ == '__main__': ######################################################### - insert_line = 'INSERT INTO feeds(link) VALUES (%s)' + sql_insert_link = 'INSERT INTO feeds(link) VALUES (%s)' + + sql_insert_ids = 'INSERT INTO id(toot_id, tweet_id) VALUES (%s,%s)' conn = None @@ -369,33 +371,9 @@ if __name__ == '__main__': cur = conn.cursor() - cur.execute(insert_line, (link,)) + cur.execute(sql_insert_link, (link,)) - conn.commit() - - cur.close() - - except (Exception, psycopg2.DatabaseError) as error: - - print(error) - - finally: - - if conn is not None: - - conn.close() - - insert_line = 'INSERT INTO id(toot_id, tweet_id) VALUES (%s,%s)' - - conn = None - - try: - - conn = psycopg2.connect(database = feeds_db, user = feeds_db_user, password = "", host = "/var/run/postgresql", port = "5432") - - cur = conn.cursor() - - cur.execute(insert_line, (toot_id, tweet.id)) + cur.execute(sql_insert_ids, (toot_id, tweet.id)) conn.commit()