Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- i have this code
- #!/usr/local/bin/python3
- locationId=3106
- import mysql.connector
- con = mysql.connector.connect(host="localhost",database="racktables",user="root",password="fullmoon")
- cur1 = con.cursor()
- query1 = "SELECT r.name AS rowName, r.id AS rowId FROM Object AS r INNER JOIN EntityLink AS e ON r.id = e.child_entity_id WHERE e.parent_entity_id = \""+str(locationId)+"\" ORDER BY r.name"
- print(query1)
- result1 = cur1.execute(query1)
- for (rowName, rowId) in result1:
- print(rowName, rowId)
- the generated query works when i use it in mysql
- mysql> SELECT r.name AS rowName, r.id AS rowId FROM Object AS r INNER JOIN EntityLink AS e ON r.id = e.child_entity_id WHERE e.parent_entity_id = "3106" ORDER BY r.name;
- +---------+-------+
- | rowName | rowId |
- +---------+-------+
- | Row A | 2519 |
- | Row B | 3107 |
- | Row C | 7983 |
- | Row D | 7985 |
- | Row E | 14277 |
- | Row F | 14319 |
- | Zero-U | 4639 |
- +---------+-------+
- but when i run my code i get this...
- Traceback (most recent call last):
- File "./blah.py", line 9, in <module>
- for (rowName, rowId) in result1:
- TypeError: 'NoneType' object is not iterable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement