sqlparse Python的无验证SQL解析器
sqlparse非验证SQL解析器
sqlparse,Python非验证SQL解析器,Python第三方库,提供对解析、拆分和格式化SQL语句的支持。
sqlparse应用实例
>>> import sqlparse
>>> # Split a string containing two SQL statements:
>>> raw = 'select * from benniao; select * from gongju;'
>>> statements = sqlparse.split(raw)
>>> statements
['select * from benniao;', 'select * from gongju;']
>>> # Format the first statement and print it out:
>>> first = statements[0]
>>> print(sqlparse.format(first, reindent=True, keyword_case='upper'))
SELECT *
FROM benniao;
>>> # Parsing a SQL statement:
>>> parsed = sqlparse.parse('select * from benniao')[0]
>>> parsed.tokens
[, ,
Github开源协议和stars
BSD-3-Clause license
Github 3.4k stars
sqlparse安装命令
pip install sqlparse
Python版本要求
Python3.6+
免责声明:内容编辑自网络,仅供参考,不保证正确性,不作任何决策依据!!以上数据皆截止于博文的写稿日期。