Skip to main content

escape_string_literal

Function escape_string_literal 

Source
pub fn escape_string_literal(value: &str) -> String
Expand description

Escapes a SQL string literal for safe use in queries.

This function properly quotes and escapes a string value to prevent SQL injection. The result is wrapped in single quotes with internal quotes escaped.

ยงExample

use hyperdb_api::escape_string_literal;

let escaped = escape_string_literal("hello");
assert_eq!(escaped, "'hello'");

let special = escape_string_literal("it's a test");
assert_eq!(special, "'it''s a test'");