Hello everybody,
I hang time again on a problem I have written with flask a restapi which works so far now I would like expand with conditional mysql queries. However, the question how I access the Variable “id” in the MYSQL “Select” . Thanks for your help


from flask import Flask
from flask_restful import Resource, Api
from flask_restful import reqparse
from flask.ext.mysql import MySQL

mysql = MySQL()
app = Flask(__name__) 

# MySQL configurations
app.config['MYSQL_DATABASE_USER'] = 'xxx'
app.config['MYSQL_DATABASE_PASSWORD'] = 'xxxx'
app.config['MYSQL_DATABASE_DB'] = 'xxxxx'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'


api = Api(app)

class test(Resource):
def post(self):
        # Parse the arguments

        parser = reqparse.RequestParser()
        parser.add_argument('ID', type=str, help='Id of Item')
        args = parser.parse_args()

        id = str(args['ID'])
        conn = mysql.connect()
        cursor = conn.cursor()
        cursor.execute("SELECT * FROM `PowerSystem` WHERE ID=$(id)")
        for item in data:
            i = {

        return {'StatusCode':'200','Items':items_list}

        except Exception as e:
        return {'error': str(e)}

api.add_resource(test, '/test')

 if __name__ == '__main__':


how is this line correct

 cursor.execute("SELECT * FROM `PowerSystem` WHERE ID=$(id)")

so that onlz the mysql data with the respective id is send


 {"error": "(1305, u'FUNCTION xxxxx.$ does not exist')"}

is send back

but the result should like

  "Items": [
  "batteryVoltage": "3.612",
  "solarVoltage": "4.725",
  "loadCurrent": "308.4",
  "ID": "112",
  "loadPower": "1.527",
  "loadVoltage": "4.952",
  "batteryCurrent": "283.2",
  "Timestamp": "2017-05-11 13:04:18",
  "solarCurrent": "191.2",
  "solarPower": "0.903",
  "batteryCharge": "24.86",
  "batteryPower": "1.023"
  "StatusCode": "200"

Thanks :)