0

I have tried multiple permutations of the following to accomplish the goal of inserting an html string into a database with type longtext.

My code looks like this:

def generic_sql_alch(sql):
    db = get_engine()
    connection = db.connect()
    connection.execute("inert into questions values (':name')",name= ( sql))
    connection.close()
    db.dispose()

The error I am getting is the following:

  File "C:\Python27\Lib\site-packages\mysql\connector\connection.py", line 722, in cmd_query
    result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
  File "C:\Python27\Lib\site-packages\mysql\connector\connection.py", line 640, in _handle_result
    raise errors.get_exception(packet)
sqlalchemy.exc.ProgrammingError: (ProgrammingError) 1064 (42000): 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 'inert into questions values (':name')' at line 1 "inert into questions values (':name')" {'name': '%0A%3B%2Fdiv%26gt%3B%09%09%09%0A%09%09%0A%09%09'}

I am unsure why as I encoded the string, escaped it etc. Banging my head against the wall on this.

The connection works, code has historically worked on more basic sql statements, but this is the first time i am needing to encode in python.

Thank you

1 Answer 1

1

I am an idiot. inert was typed, not insert.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.