I have tried to write a if statement to combine two functions into one but it 's not working . These two functions has no any errors and my teammate needs me to combine two functions into one and receive two table 's field in one function. before the functions(receiving two table's field for each function):
def readrouter(x):
conn = sqlite3.connect('server.db')
cur = conn.cursor()
cur.execute("SELECT DISTINCT command FROM router WHERE function =? or function='configure terminal' or function='enable' ORDER BY key ASC",(x,))
read = cur.fetchall()
return read;
a = input("x:")
for result in readrouter(a):
print (result[0])
# def readswitch(x):
# conn = sqlite3.connect('server.db')
# cur = conn.cursor()
# cur.execute("SELECT DISTINCT command FROM switch WHERE function =? or function='configure terminal' or function='enable' ORDER BY key ASC",(x,))
# read = cur.fetchall()
# return read;
#
# a = input("x:")
# for result in readswitch(a):
# print (result[0])
After i follow some if statement and write new one:
# def readciscodevice(x):
# var = 1
# conn = sqlite3.connect('server.db')
# cur = conn.cursor()
# if var == 1:
# cur.execute(
# "SELECT DISTINCT command FROM switch WHERE function =? or function='configure terminal' or function='enable' ORDER BY key ASC",
# (x,))
# read = cur.fetchall()
# return read
# else:
# cur.execute(
# "SELECT DISTINCT command FROM router WHERE function =? or function='configure terminal' or function='enable' ORDER BY key ASC",
# (x,))
# read = cur.fetchall()
# return read;
#
#
# a = input("x:")
# for result in readciscodevice(a):
# print(result[0])
I could draw my commands in switch 's table but cant receive any commands from table's router Any one help me to correct my if-statement's mistake? Thank you so much!
Aucun commentaire:
Enregistrer un commentaire