METADATA 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. Metadata-Version: 2.1
  2. Name: sqlparse
  3. Version: 0.3.1
  4. Summary: Non-validating SQL parser
  5. Home-page: https://github.com/andialbrecht/sqlparse
  6. Author: Andi Albrecht
  7. Author-email: albrecht.andi@gmail.com
  8. License: BSD
  9. Platform: UNKNOWN
  10. Classifier: Development Status :: 5 - Production/Stable
  11. Classifier: Intended Audience :: Developers
  12. Classifier: License :: OSI Approved :: BSD License
  13. Classifier: Operating System :: OS Independent
  14. Classifier: Programming Language :: Python
  15. Classifier: Programming Language :: Python :: 2
  16. Classifier: Programming Language :: Python :: 2.7
  17. Classifier: Programming Language :: Python :: 3
  18. Classifier: Programming Language :: Python :: 3.4
  19. Classifier: Programming Language :: Python :: 3.5
  20. Classifier: Programming Language :: Python :: 3.6
  21. Classifier: Programming Language :: Python :: 3.7
  22. Classifier: Programming Language :: Python :: 3.8
  23. Classifier: Topic :: Database
  24. Classifier: Topic :: Software Development
  25. Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
  26. ``sqlparse`` is a non-validating SQL parser module.
  27. It provides support for parsing, splitting and formatting SQL statements.
  28. Visit the `project page <https://github.com/andialbrecht/sqlparse>`_ for
  29. additional information and documentation.
  30. **Example Usage**
  31. Splitting SQL statements::
  32. >>> import sqlparse
  33. >>> sqlparse.split('select * from foo; select * from bar;')
  34. [u'select * from foo; ', u'select * from bar;']
  35. Formatting statements::
  36. >>> sql = 'select * from foo where id in (select id from bar);'
  37. >>> print(sqlparse.format(sql, reindent=True, keyword_case='upper'))
  38. SELECT *
  39. FROM foo
  40. WHERE id IN
  41. (SELECT id
  42. FROM bar);
  43. Parsing::
  44. >>> sql = 'select * from someschema.mytable where id = 1'
  45. >>> res = sqlparse.parse(sql)
  46. >>> res
  47. (<Statement 'select...' at 0x9ad08ec>,)
  48. >>> stmt = res[0]
  49. >>> str(stmt) # converting it back to unicode
  50. 'select * from someschema.mytable where id = 1'
  51. >>> # This is how the internal representation looks like:
  52. >>> stmt.tokens
  53. (<DML 'select' at 0x9b63c34>,
  54. <Whitespace ' ' at 0x9b63e8c>,
  55. <Operator '*' at 0x9b63e64>,
  56. <Whitespace ' ' at 0x9b63c5c>,
  57. <Keyword 'from' at 0x9b63c84>,
  58. <Whitespace ' ' at 0x9b63cd4>,
  59. <Identifier 'somes...' at 0x9b5c62c>,
  60. <Whitespace ' ' at 0x9b63f04>,
  61. <Where 'where ...' at 0x9b5caac>)