I'm trying to read from a certain row in an MySQL data base. I'm getting an InterfaceError on line 17.
The full error:
(0, ''): InterfaceError Traceback (most recent call last): File "/var/task/handler.py", line 17, in main cur.execute(sql)
I tested the MySQL query by it self and it works just fine. The program is using the Serverless Framework hosted on Amazon Lambda.
import json
import common
import pymysql
db = pymysql.connect(host="example.com",
user="admin",
passwd="Foo",
db="Bar")
def main(event, context):
sql = "SELECT * FROM Accounts WHERE Username ='Caleb'"
cur = db.cursor()
cur.execute(sql)
result = cur.fetchall()
cur.close()
db.close()
data = pwd + usern
alldata = data + result
return dict(
statusCode=200,
body=json.dumps(alldata)
)
return response