Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def open_db():
- cnx = mysql.connector.connect(
- user='xxxxxxxx',
- password='xxxxxxxx',
- host='127.0.0.1',
- database='xxxxxxx',
- charset='utf8'
- )
- return cnx
- class User(Resource):
- def get(self, id):
- print(id)
- db = open_db()
- cursor = db.cursor(prepared=True)
- sql = ("SELECT username, twitter, instagram FROM user WHERE id = %s LIMIT 1")
- cursor.execute(sql, (id))
- user = cursor.fetchone()
- db.close()
- return jsonify({
- 'username': user[0].decode()
- })
Add Comment
Please, Sign In to add comment