Here is the python code I am running.
def queryOrg(self, OrgID):
session = mysqlx.get_session(
{'host': db.HOST, 'port': db.PORT, 'user': db.USER, 'password': db.PASSWORD})
org_schema = session.get_schema('Organizations')
org_table = org_schema.get_table('Organizations')
result = org_table.select(["*"]).where('Organization_ID = ' + str(OrgID)).execute()
print(result)
And here is the error output
mysqlx.errors.OperationalError: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS `*` FROM `Organizations`.`Organizations` WHERE (`Organization_ID` = 2)' at line 1
When I run...
def queryOrg(self, OrgID):
session = mysqlx.get_session(
{'host': db.HOST, 'port': db.PORT, 'user': db.USER, 'password': db.PASSWORD})
org_schema = session.get_schema('Organizations')
org_table = org_schema.get_table('Organizations')
result = org_table.select(["*"]).where('Organization_ID = ' + str(OrgID)).get_sql()
print(result)
I get this output.
SELECT * FROM Organizations.Organizations WHERE Organization_ID = 2
So, it seems to be generating the correct mysql query when I use the .get_sql() method, but when I call the .execute() method somehting changes the query to 'AS *
FROM Organizations
.Organizations
WHERE (Organization_ID
= 2)'
I have no idea why this would be happening. I am running a MySQL server on a ubuntu rasberry pi, version 8.031-0ubuntu0.22.04.1 and I am running python 3.8.10 with pip3 mysql-connector-python 8.0.30.
This function is getting called through a flask app. I am running flask on version 2.2.2
Any help at all would be very welcome.