From 098e05360b3fb20e766b6d0c9765f277e6ae745e Mon Sep 17 00:00:00 2001 From: HuilinWu2 <68987242+HuilinWu2@users.noreply.github.com> Date: Fri, 1 Apr 2022 15:26:47 +0800 Subject: [PATCH] Update dbapi.py (#1562) --- python/openmldb/dbapi/dbapi.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/python/openmldb/dbapi/dbapi.py b/python/openmldb/dbapi/dbapi.py index ece660ae8a5..16d724f680d 100644 --- a/python/openmldb/dbapi/dbapi.py +++ b/python/openmldb/dbapi/dbapi.py @@ -246,7 +246,20 @@ def execute(self, operation, parameters=()): command = operation.strip(' \t\n\r') if operation else None if command is None: raise Exception("None operation") - if insertRE.match(command): + semicolonCount = command.count(';') + escapeSemicolonCount = command.count("\;") + if createTableRE.match(command): + if escapeSemicolonCount > 1: + raise Exception("invalid table name") + ok, error = self.connection._sdk.executeDDL(self.db, command) + if not ok: + raise DatabaseError(error) + elif createDBRE.match(command): + db = command.split()[-1].rstrip(";") + ok, error = self.connection._sdk.createDB(db) + if not ok: + raise DatabaseError(error) + elif insertRE.match(command): questionMarkCount = command.count('?') if questionMarkCount > 0: if len(parameters) != questionMarkCount: