Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import MySQLdb
- user_input = raw_input("Please enter barcode and press Enter button: ")
- db = MySQLdb.connect(passwd="moonpie",db="thangs")
- mycursor = db.cursor()
- mycursor.execute("""SELECT name, price FROM Product
- WHERE barcode = %s""", (user_input,))
- # calls fetchone until None is returned (no more rows)
- for row in iter(mycursor.fetchone, None):
- print row
- product = session.query(Product).filter(Product.barcode == user_input).scalar()
- print product.name, product.price
Add Comment
Please, Sign In to add comment