escape_string()

Overview

Returns a backslash-escaped string that can be used inside single or double quotes in an SQL statement.

See also: MariaDB Connector/Python 1.1 and in 1.0

EXAMPLES

import mariadb

conn = mariadb.connect(
    host = 'localhost',
    user = 'root',
    password = 'secret',
    database = 'test',
    )

x = conn.escape_string("""
    This will backslash-escape characters such as literal
    newlines, single quotes ('), and double quotes (").
    """)
print(x)

CHANGE HISTORY

Release Series

History

1.1

  • Present starting in MariaDB Connector/Python 1.1.0rc1.

1.0

  • Present starting in MariaDB Connector/Python 1.0.0.