-
Notifications
You must be signed in to change notification settings - Fork 5
/
lab_inject.py
35 lines (26 loc) · 876 Bytes
/
lab_inject.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sys
import sqlite3 as sql
def main():
sqliteFile = 'pokedex.sqlite'
try:
con = sql.connect(sqliteFile)
cur = con.cursor()
print('Find all the pokemon related to ______')
userInput = input('>')
cur.execute('''SELECT a.identifier
FROM pokemon_species AS a
LEFT JOIN pokemon_species AS b
ON a.evolution_chain_id = b.evolution_chain_id
WHERE b.identifier = LOWER("%s");''' % userInput )
for name, in cur:
print(name, end=', ')
print()
except TypeError:
print('Couldn\'t find %s in database' % userInput)
except sql.Error as e:
print("Error %s:" % e.args[0])
finally:
if con:
con.close()
if __name__ == '__main__':
sys.exit(main())