I'm having a problem and I think that I'm missing something very basic. I'm kind of a noob if it comes to programming but I guess I learn quick. I'm trying to make a Python script that asks for user input and then performs Postgresql SELECT. Then, the outcome of SELECT should be put into another script that uses SSH but I can't wrap my head around that SELECT query. There is a basic example of my code, if you have any tips I would appreciate greatly:
print('Diagnostic tool')
print('')
print('Please insert account ID:')
input()
try:
conn = psycopg2.connect("dbname='psql' user='user' host='localhost'
password='pasword'")
cur = conn.cursor()
cur.execute("SELECT * FROM exampletable WHERE acc_id = #userinput ")
cur.fetchall()
except:
print ("Could not establish connection to Database")
As shown above- how do I perform a query that uses SELECT WHERE table name is user input (acc_id)?