I’m creating a dynamic Insert query.
sql = "INSERT INTO `" + self.db_name + "` (" sql += ','.join(e.db_name for e in self.fields) sql += ") VALUES (" sql += ','.join(("'" + e.value + "'") for e in self.fields) sql += ");" result = s.execute(sql) It works fine, except the inserted value is not safe of special characters and SQL injection.
I cant use the SqlAlchemy text() mechanism because i don’t know the names or quantity of fields in table.
I tryed MySQLdb.escape_string(), but its not working with Unicode.
How can i make a dynamic sql Insert query while escaping special characters in unicode value?
table()andcolumn(), the light weight analogues ofTableandColumn, but this reeks of an XY problem. Why would one not know the names of their tables etc.?