Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get tablename #535

Open
lmy1223 opened this issue Feb 26, 2020 · 1 comment
Open

how to get tablename #535

lmy1223 opened this issue Feb 26, 2020 · 1 comment

Comments

@lmy1223
Copy link

lmy1223 commented Feb 26, 2020

hi ~ If provide an SQL parameter, how to get the SQL tablename?
thanks ~

@yzjkzq
Copy link

yzjkzq commented Jul 15, 2020

def getTableName(sql):
result = set()
tokens = re.split(r"[\s)(;`]+", sql.upper())
get_next = False
for tok in tokens:
if get_next:
if tok not in ["", "SELECT"]:
result.add(tok)
get_next = False
get_next = tok in ['INTO','FROM','JOIN']
return result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants