utils.py 383 B

123456789101112
  1. """
  2. Database utility functions for PostgreSQL operations.
  3. """
  4. def psql_quote_literal(value: str) -> str:
  5. """Safely quote a string literal for PostgreSQL to prevent SQL injection.
  6. This is a simple implementation - in production, you should use proper parameterization
  7. or your database driver's quoting functions.
  8. """
  9. return "'" + value.replace("'", "''") + "'"