Skip to content

Commit

Permalink
escape sql string for SDL
Browse files Browse the repository at this point in the history
Signed-off-by: LetongHan <letong.han@intel.com>
  • Loading branch information
letonghan committed Nov 6, 2023
1 parent 27c5d1e commit be6790a
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from .config import get_settings
from pymysql import connect, cursors
from pymysql.converters import escape_string
from contextlib import contextmanager

global_settings = get_settings()
Expand Down Expand Up @@ -55,11 +56,15 @@ def transaction(self):
raise e

def fetch_one(self, sql, params=None):
self._cursor.execute(sql, params)
escape_sql = escape_string(sql)
print(f"escape sql: {escape_sql}")
self._cursor.execute(escape_sql, params)
return self._cursor.fetchone()

def fetch_all(self, sql, params=None):
self._cursor.execute(sql, params)
escape_sql = escape_string(sql)
print(f"escape sql: {escape_sql}")
self._cursor.execute(escape_sql, params)
return self._cursor.fetchall()

def insert(self, sql, params):
Expand Down

0 comments on commit be6790a

Please sign in to comment.