赞
踩
import sqlparse
from sqlparse.sql import IdentifierList, Identifier
from sqlparse.tokens import Keyword, DML
# 支持的join方式
ALL_JOIN_TYPE = ('LEFT JOIN', 'RIGHT JOIN', 'INNER JOIN', 'FULL JOIN', 'LEFT OUTER JOIN', 'FULL OUTER JOIN')
def is_subselect(parsed):
"""
是否子查询
:param parsed:
:return:
"""
if not parsed.is_group:
return False
for item in parsed.tokens:
if item.ttype is DML and item.value.upper() == 'SELECT':
return True
return False
def extract_from_part(parsed):
"""
提取from之后模块
:param parsed:
:return:
"""
from_seen = False
for item in parsed.tokens:
if from_seen:
if is_subselect(item):
for x
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。