提交 d8074026 编写于 作者: W wenzhouwww@live.cn

update codes to support dynamic full_table_name when use it

上级 024ca23c
......@@ -1687,11 +1687,13 @@ class TdSuperTable:
def __init__(self, stName, dbName):
self._stName = stName
self._dbName = dbName
self._fullTableName = dbName + '.' + stName
def getName(self):
return self._stName
def getFullTableName(self):
return self._dbName + '.' + self._stName
def drop(self, dbc, skipCheck = False):
dbName = self._dbName
if self.exists(dbc) : # if myself exists
......@@ -1699,11 +1701,11 @@ class TdSuperTable:
dbc.execute("DROP TaBLE {}".format(fullTableName))
else:
if not skipCheck:
raise CrashGenError("Cannot drop non-existant super table: {}".format(self._fullTableName))
raise CrashGenError("Cannot drop non-existant super table: {}".format(fullTableName))
def exists(self, dbc):
dbc.execute("USE " + self._dbName)
return dbc.existsSuperTable(self._dbName, self._fullTableName)
return dbc.existsSuperTable(self._dbName, self._stName)
# TODO: odd semantic, create() method is usually static?
def create(self, dbc, cols: TdColumns, tags: TdTags, dropIfExists = False):
......@@ -1712,11 +1714,11 @@ class TdSuperTable:
dbName = self._dbName
dbc.execute("USE " + dbName)
fullTableName = dbName + '.' + self._stName
if dbc.existsSuperTable(self._dbName, self._fullTableName):
if dbc.existsSuperTable(dbName, self._stName):
if dropIfExists:
dbc.execute("DROP TAbLE {}".format(fullTableName))
else: # error
raise CrashGenError("Cannot create super table, already exists: {}".format(self._fullTableName))
raise CrashGenError("Cannot create super table, already exists: {}".format(self._stName))
# Now let's create
sql = "CREATE TABLE {} ({})".format(
......
......@@ -101,12 +101,12 @@ class DbConn:
return dbName in dbs # TODO: super weird type mangling seen, once here
def existsSuperTable(self, dbName, stName):
self.query(f"show {dbName}.stables")
self.query("show {}.stables".format(dbName))
sts = [v[0] for v in self.getQueryResult()]
return stName in sts
def hasTables(self, dbName):
return self.query(f"show {dbName}.tables") > 0
return self.query("show {}.tables".format(dbName)) > 0
def execute(self, sql):
''' Return the number of rows affected'''
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册