Skip to content

Commit

Permalink
Update dbapi.py (4paradigm#1562)
Browse files Browse the repository at this point in the history
  • Loading branch information
HuilinWu2 authored Apr 1, 2022
1 parent b10fe6d commit 098e053
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion python/openmldb/dbapi/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 098e053

Please sign in to comment.