def get_user(): conn = connect_db() cur = conn.cursor() cur.execute( "SELECT id, name, twitter as screen_name, comment, sex, image from users where " + request.form['user_id'] + " = id") result = cur.fetchone() cur.execute("SELECT * from user_tags where user_id = %s", (request.form['user_id'], )) tag_result = cur.fetchall() cur.close() conn.commit() conn.close() if result is None: return jsonify(result='') result['twitter'] = analyze(result['screen_name']) tags = [] for r in tag_result: tags.append(r['name']) result['tags'] = tags return jsonify(result=result)
def post_location(): conn = connect_db() cur = conn.cursor() cur.execute( "update `locations` set position = GeomFromText('POINT(" + request.form['lng'] + " " + request.form['lat'] + ")') where user_id=%s", request.form['user_id']) conn.commit() cur.close() conn.close conn = connect_db() cur = conn.cursor() cur.execute( "SELECT yahhos.id AS id, X(position) AS lng, Y(position) AS lat, users.name, comment, twitter as screen_name, pushed_user_id, pushing_user_id, reply, sex, image FROM yahhos LEFT JOIN users ON yahhos.pushing_user_id = users.id WHERE pushed_user_id = " + request.form['user_id']) result = cur.fetchone() if result is not None: cur.execute("DELETE FROM yahhos WHERE id = %s", (result['id'], )) if result is None: cur.close() conn.commit() conn.close return jsonify(result='') cur.execute("SELECT * from user_tags where user_id = %s", (result['pushing_user_id'], )) tag_result = cur.fetchall() cur.close() conn.commit() conn.close result['twitter'] = analyze(result['screen_name']) tags = [] for r in tag_result: tags.append(r['name']) result['tags'] = tags return jsonify(result=result)
def get_user(): conn = connect_db() cur = conn.cursor() cur.execute("SELECT id, name, twitter as screen_name, comment, sex, image from users where " + request.form['user_id'] + " = id") result = cur.fetchone() cur.execute("SELECT * from user_tags where user_id = %s", (request.form['user_id'],)) tag_result = cur.fetchall() cur.close() conn.commit() conn.close() if result is None: return jsonify(result='') result['twitter'] = analyze(result['screen_name']) tags = [] for r in tag_result: tags.append(r['name']) result['tags'] = tags return jsonify(result=result)
def post_location(): conn = connect_db() cur = conn.cursor() cur.execute("update `locations` set position = GeomFromText('POINT(" + request.form['lng'] + " " + request.form['lat'] + ")') where user_id=%s", request.form['user_id']) conn.commit() cur.close() conn.close conn = connect_db() cur = conn.cursor() cur.execute("SELECT yahhos.id AS id, X(position) AS lng, Y(position) AS lat, users.name, comment, twitter as screen_name, pushed_user_id, pushing_user_id, reply, sex, image FROM yahhos LEFT JOIN users ON yahhos.pushing_user_id = users.id WHERE pushed_user_id = " + request.form['user_id']) result = cur.fetchone() if result is not None: cur.execute("DELETE FROM yahhos WHERE id = %s", (result['id'],)) if result is None: cur.close() conn.commit() conn.close return jsonify(result='') cur.execute("SELECT * from user_tags where user_id = %s", (result['pushing_user_id'],)) tag_result = cur.fetchall() cur.close() conn.commit() conn.close result['twitter'] = analyze(result['screen_name']) tags = [] for r in tag_result: tags.append(r['name']) result['tags'] = tags return jsonify(result=result)