[英]pymysql reading \n characters. how can I stop \n characters being run in an .sql file?
Error:错误:
pymysql.err.ProgrammingError: (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 'CREATE
PROCEDURE
`sp_listProducts` (\n SELECT p.product_id\n , p.pr' at line 3")
SQL:查询语句:
CREATE PROCEDURE `sp_listProducts` ()
SELECT p.product_id
, p.product
, u.unit
, p.unit_quantity
, p.unit_weight
, p.pr_number
, pj.project_code
, sec.sector
, p.supplier
, p.packaging_info
, loc.location AS project_location
, p.comments
, loc.location_id
, p.product_price
, p.price_currency
, p.gik_number
, p.gik_stock_id
, p.gik_supplier_id AS supplier_id
, gik.gik_supplier
, IF(tr.in_stock > 0, tr.in_stock, 0) as in_stock
FROM tbl_product AS p
# get all FK values for display
LEFT JOIN tbl_unit AS u ON p.unit_id = u.unit_id
LEFT JOIN tbl_project AS pj ON p.project_id = pj.project_id
LEFT JOIN tbl_location AS loc ON pj.location_id = loc.location_id
lEFT JOIN tbl_sector AS sec ON p.sector_id = sec.sector_id
LEFT JOIN tbl_gik_supplier AS gik ON p.gik_supplier_id = gik.gik_supplier_id
LEFT JOIN (
SELECT product_id
, SUM(IF(trans_type IN ('in', 'count-gain', 'wb-gain'), trans_quantity, 0)) as inflow
, SUM(IF(trans_type IN ('out', 'count-loss', 'wb-loss'), trans_quantity, 0)) as outflow
, SUM(IF(trans_type IN ('in', 'count-gain', 'wb-gain'), trans_quantity, 0)) - SUM(IF(trans_type IN ('out', 'count-loss', 'wb-loss'), trans_quantity, 0)) as in_stock
FROM tbl_transaction
WHERE deleted=0
GROUP By product_id
) tr
ON p.product_id = tr.product_id
ORDER BY p.product_id ASC;
I've tried changing the encoding to UTF-8 to no avail.我尝试将编码更改为 UTF-8 无济于事。 I've also set the project settins.json "files.encoding": "utf8" in vscode;
我还在 vscode 中设置了项目 settins.json "files.encoding": "utf8"; didn't work.
没有用。 How do I get rid of the "\\n" characters being read?
如何摆脱正在读取的“\\n”字符?
\\n
is not the villain. \\n
不是反派。 Based on the error message, it is either the CREATE
token or whatever came immediately before it.根据错误消息,它要么是
CREATE
令牌,要么是它之前的任何东西。 I expect it to be a syntax error in the DELIMITER
statement.我希望它是
DELIMITER
语句中的语法错误。 A common cause:一个常见的原因:
DELIMITER// -- bad; need space after "DELIMITER" and the delimiter
Check the docs on pymysql
-- perhaps DELIMITER
is not used, and it is something else.检查
pymysql
上的文档——也许没有使用DELIMITER
,它是别的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.