文件首頁
MySQL Connector/Python 開發者指南
相關文件 下載本手冊
PDF (美式信紙) - 0.7Mb
PDF (A4) - 0.7Mb


MySQL Connector/Python 開發者指南  /  Connector/Python C 擴充功能 API 參考  /  _mysql_connector.MySQL.escape_string() 方法

11.14 _mysql_connector.MySQL.escape_string() 方法

語法

str = ccnx.escape_string(str_to_escape)

使用 mysql_escape_string() C API 函式來建立可用於 SQL 陳述式中的 SQL 字串。

如果值不具有 Unicodebytes 或 (對於 Python 2) string 類型,則會引發 TypeError 例外。如果字串無法逸出,則會引發 MySQLError 例外。