Make database selectable

Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
fly 2021-03-13 01:08:57 +00:00
parent 20da6220a2
commit c59366776b

View file

@ -28,6 +28,7 @@ port = 12345
verbose = False
dbuser = ""
dbpw = ""
dbname = "worldbuild"
argc = len(sys.argv)
i = 1
@ -44,6 +45,9 @@ while i < argc:
elif sys.argv[i] == "-p" or sys.argv[i] == "--password":
i += 1
dbpw = sys.argv[i]
elif sys.argv[i] == "-d" or sys.argv[i] == "--database":
i += 1
dbname = sys.argv[i]
elif sys.argv[i] == "-v":
verbose = True
elif sys.argv[i] == "-h" or sys.argv[i] == "--help":
@ -51,6 +55,7 @@ while i < argc:
print("Handles job asignments and keeps track of the status")
print("")
print("OPTIONS")
print(" -d, --database Database name")
print(" -u, --user Database user")
print(" -p, --password Database password")
print(" -v, --verbose Verbose printouts")
@ -71,7 +76,7 @@ if dbpw == "":
print("ERROR: No database password given")
sys.exit(1)
db = pymysql.connect("localhost", dbuser, dbpw, "worldbuild")
db = pymysql.connect("localhost", dbuser, dbpw, dbname)
cursor = db.cursor()