pypika
pypika copied to clipboard
Table name in get_sql() should not surrounded by double quotes.
Table name in get_sql() should not surrounded by double quotes.It's not a valid sql statment in MySQL.Please use back quotes(`) instead.
bad case:
from pypika import MySQLQuery as Query
from pypika import Table
q = Query.into(Table('tbl_name').insert(1, 'Allen')
q.get_sql();
INSERT INTO "tbl_name" VALUES(1, "Allen");
good case:
INSERT INTO `tbl_name` VALUES(1, "Allen");
Try this
>>> from pypika import MySQLQuery as Query
>>> from pypika import Table
>>> q = Query.into(Table('tbl_name').insert(1, 'Allen').get_sql();
INSERT INTO `tbl_name` VALUES (1,'Allen')
Or using quote_char
argument when calling get_sql()
, though that seems pretty redundant:
Reference: https://github.com/kayak/pypika/issues/14