Skip to content

Instantly share code, notes, and snippets.

@elseagle
Last active May 25, 2019 03:29
Show Gist options
  • Save elseagle/aa6d715f68841e1f91046c960e443dc8 to your computer and use it in GitHub Desktop.
Save elseagle/aa6d715f68841e1f91046c960e443dc8 to your computer and use it in GitHub Desktop.
def find_by_name(name):
connection = sqlite3.connect('data.db')
cursor = connection.cursor()
query = "SELECT * FROM items WHERE name=?"
result = cursor.execute(query, (name,))
row = result.fetchone()
connection.close()
if row:
return jsonify({'item': {'name': row[0], 'price': row[1]}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment