本文整理汇总了Python中database.DataBase.has_table方法的典型用法代码示例。如果您正苦于以下问题:Python DataBase.has_table方法的具体用法?Python DataBase.has_table怎么用?Python DataBase.has_table使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database.DataBase
的用法示例。
在下文中一共展示了DataBase.has_table方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ParseSql
# 需要导入模块: from database import DataBase [as 别名]
# 或者: from database.DataBase import has_table [as 别名]
class ParseSql():
def __init__(self):
self.parsefunc = {}
self.dbhandle = DataBase()
self.userpermit = []
import parsefunc
self.load_func(parsefunc)
def load_func(self,mod):
m = dir(mod)
for func in m:
f = getattr(mod, func)
if callable(f) and hasattr(f, "__sql__"):
name = getattr(f, "__sql__").upper()
self.parsefunc[name] = f
def parse_sql(self,sql):
sql = rmNoUseChar(sql)
sql = upperKetWord(sql)
if "quit" in sql:
import sys
sys.exit(0)
funcname = sql.split(" ")[0].upper()
if self.parsefunc.has_key(funcname):
if funcname not in self.userpermit:
raise UNAUTHORIZED(funcname)
sql.rstrip(";")
self.parsefunc[funcname](self.dbhandle,sql)
else:
raise SYNTAXERROR
def clean_sql(self,sql):
sql.rstrip()
sql.strip()
return sql
def set_user_permit(self,user,permit):
self.user = user
self.userpermit = permit
def update_userpermission(self,users,permission):
for per in permission:
tlist = permission[per]
for table in tlist:
if not self.dbhandle.has_table(table):
print "%s not exist"%table
tlist.remove(table)
permission[per] = tlist
self.user.update_user(user,permission)
def __get_user_input__():
while True:
sql = ""
while ";" not in sql:
sql += raw_input()+" "
self.parse_sql(sql)
def CheckSelect(self,sqldic):
tables = sqlDic["FROM"]
selects = sqlDic["SELECT"]
wheres = sqlDic["WHERE"]
groups = sqlDic["GROUP"]
orders = sqlDic["ORDER"]
self.dbhandle.checkTable(tables,meta)
sqlDic["SELECT"] = self.dbhandle.checkSelect(selects,tables,meta)
sqlDic["WHERE"] = self.dbhandle.checkWhere(wheres,tables,meta)
sqlDic["GROUP"] = self.dbhandle.checkGroup(groups,tables,meta)
sqlDic["ORDER"] = self.dbhandle.checkOrder(orders,tables,meta)
self.dbhandle.do_select(sqlDic)