From 4f810126452846dc3df9201ed1b7b2f13bf51a7d Mon Sep 17 00:00:00 2001 From: spla Date: Sat, 24 Oct 2020 10:48:23 +0200 Subject: [PATCH] Fixed indents --- db-setup.py | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/db-setup.py b/db-setup.py index cf0e542..ab5606f 100644 --- a/db-setup.py +++ b/db-setup.py @@ -29,42 +29,42 @@ def get_parameter( parameter, file_path ): sys.exit(0) def write_parameter( parameter, file_path ): - print("Setting up newsfeed parameters...") - print("\n") - feeds_db = input("feeds db name: ") - feeds_db_user = input("feeds db user: ") - feeds_url = input("enter feeds url: ") + print("Setting up newsfeed parameters...") + print("\n") + feeds_db = input("feeds db name: ") + feeds_db_user = input("feeds db user: ") + feeds_url = input("enter feeds url: ") - with open(file_path, "w") as text_file: - print("feeds_db: {}".format(feeds_db), file=text_file) - print("feeds_db_user: {}".format(feeds_db_user), file=text_file) - print("feeds_url: {}".format(feeds_url), file=text_file) + with open(file_path, "w") as text_file: + print("feeds_db: {}".format(feeds_db), file=text_file) + print("feeds_db_user: {}".format(feeds_db_user), file=text_file) + print("feeds_url: {}".format(feeds_url), file=text_file) def create_table(db, db_user, table, sql): - conn = None - try: + conn = None + try: - conn = psycopg2.connect(database = db, user = db_user, password = "", host = "/var/run/postgresql", port = "5432") - cur = conn.cursor() + conn = psycopg2.connect(database = db, user = db_user, password = "", host = "/var/run/postgresql", port = "5432") + cur = conn.cursor() - print("Creating table.. "+table) - # Create the table in PostgreSQL database - cur.execute(sql) + print("Creating table.. "+table) + # Create the table in PostgreSQL database + cur.execute(sql) - conn.commit() - print("Table "+table+" created!") - print("\n") + conn.commit() + print("Table "+table+" created!") + print("\n") - except (Exception, psycopg2.DatabaseError) as error: + except (Exception, psycopg2.DatabaseError) as error: - print(error) + print(error) - finally: + finally: - if conn is not None: + if conn is not None: - conn.close() + conn.close() ############################################################################### # main