Mar-26-2018, 06:31 PM
Hello,
I'm looking to post a list of databases from a dictionary, then from the user input choose which database they want to connect.
Any help is appreciated.
Thanks,
Frank
I'm looking to post a list of databases from a dictionary, then from the user input choose which database they want to connect.
import pprint, os db_list = { 1: {'name': 'TEST11C'}, 2: {'name': 'TEST12C'}, } print("Databases:") for x, y in db_list.items(): print(x, y) while True: print("Select a database: ") name = int(input()) if name in db_list.keys(): print("You have chosen: " + name) else: print('You chosen wrong!')The user will select a database value based on the key integers of [1,2]. If they select out of that range they'll receive an error. If they select within the range it will take the value of the database.
Any help is appreciated.
Thanks,
Frank