From 36db04c362de341014d6656685466b5dc8c4a931 Mon Sep 17 00:00:00 2001 From: spla Date: Sat, 21 Mar 2020 20:11:45 +0100 Subject: [PATCH] Updated db-setup.py --- db-setup.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/db-setup.py b/db-setup.py index d9bc8b0..765496f 100644 --- a/db-setup.py +++ b/db-setup.py @@ -29,15 +29,13 @@ def get_parameter( parameter, file_path ): sys.exit(0) def write_parameter( parameter, file_path ): - print("Setting up host parameters...") + print("Setting up newsfeed parameters...") print("\n") - mastodon_hostname = input("Enter Mastodon hostname: ") 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("mastodon_hostname: {}".format(mastodon_hostname), file=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) @@ -71,8 +69,7 @@ def create_table(db, db_user, table, sql): ############################################################################################# # Load configuration from config file -config_filepath = "config.txt" -mastodon_hostname = get_parameter("mastodon_hostname", config_filepath) +config_filepath = "db_config.txt" feeds_db = get_parameter("feeds_db", config_filepath) feeds_db_user = get_parameter("feeds_db_user", config_filepath) feeds_url = get_parameter("feeds_url", config_filepath) @@ -121,7 +118,7 @@ except (Exception, psycopg2.DatabaseError) as error: print(error) # Load configuration from config file - os.remove("config.txt") + os.remove("db_config.txt") print("Exiting. Run setup again with right parameters") sys.exit(0) @@ -141,7 +138,7 @@ print("Creating table...") db = feeds_db db_user = feeds_db_user -table = "newsfeed" +table = "feeds" sql = "create table "+table+" (link varchar(200) PRIMARY KEY)" create_table(db, db_user, table, sql)