parsing SQL with python to find specific statements
问题 I am using sqlparse to try and find specific statements. code: import sqlparse text = 'SELECT * FROM dbo.table' parse = sqlparse.parse(text) pizza = [t for t in parse[0].tokens if t.ttype in (sqlparse.tokens.Keyword)] I get [<DML 'SELECT' at 0x9f12318>, <Keyword 'FROM' at 0x9f12548>] but what I really want is to return the table name: dbo.table how can I do that? My end goal is to parse through folders of sql scripts and find references and other details. 回答1: If you print each of the tokens