METADATA 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. Metadata-Version: 2.4
  2. Name: sqlparse
  3. Version: 0.5.5
  4. Summary: A non-validating SQL parser.
  5. Project-URL: Home, https://github.com/andialbrecht/sqlparse
  6. Project-URL: Documentation, https://sqlparse.readthedocs.io/
  7. Project-URL: Release Notes, https://sqlparse.readthedocs.io/en/latest/changes.html
  8. Project-URL: Source, https://github.com/andialbrecht/sqlparse
  9. Project-URL: Tracker, https://github.com/andialbrecht/sqlparse/issues
  10. Author-email: Andi Albrecht <albrecht.andi@gmail.com>
  11. License-File: AUTHORS
  12. License-File: LICENSE
  13. Classifier: Development Status :: 5 - Production/Stable
  14. Classifier: Intended Audience :: Developers
  15. Classifier: License :: OSI Approved :: BSD License
  16. Classifier: Operating System :: OS Independent
  17. Classifier: Programming Language :: Python
  18. Classifier: Programming Language :: Python :: 3
  19. Classifier: Programming Language :: Python :: 3 :: Only
  20. Classifier: Programming Language :: Python :: 3.8
  21. Classifier: Programming Language :: Python :: 3.9
  22. Classifier: Programming Language :: Python :: 3.10
  23. Classifier: Programming Language :: Python :: 3.11
  24. Classifier: Programming Language :: Python :: 3.12
  25. Classifier: Programming Language :: Python :: 3.13
  26. Classifier: Programming Language :: Python :: 3.14
  27. Classifier: Programming Language :: Python :: Implementation :: CPython
  28. Classifier: Programming Language :: Python :: Implementation :: PyPy
  29. Classifier: Topic :: Database
  30. Classifier: Topic :: Software Development
  31. Requires-Python: >=3.8
  32. Provides-Extra: dev
  33. Requires-Dist: build; extra == 'dev'
  34. Provides-Extra: doc
  35. Requires-Dist: sphinx; extra == 'doc'
  36. Description-Content-Type: text/x-rst
  37. python-sqlparse - Parse SQL statements
  38. ======================================
  39. |buildstatus|_
  40. |coverage|_
  41. |docs|_
  42. |packageversion|_
  43. .. docincludebegin
  44. sqlparse is a non-validating SQL parser for Python.
  45. It provides support for parsing, splitting and formatting SQL statements.
  46. The module is compatible with Python 3.8+ and released under the terms of the
  47. `New BSD license <https://opensource.org/licenses/BSD-3-Clause>`_.
  48. Visit the project page at https://github.com/andialbrecht/sqlparse for
  49. further information about this project.
  50. Quick Start
  51. -----------
  52. .. code-block:: sh
  53. $ pip install sqlparse
  54. .. code-block:: python
  55. >>> import sqlparse
  56. >>> # Split a string containing two SQL statements:
  57. >>> raw = 'select * from foo; select * from bar;'
  58. >>> statements = sqlparse.split(raw)
  59. >>> statements
  60. ['select * from foo;', 'select * from bar;']
  61. >>> # Format the first statement and print it out:
  62. >>> first = statements[0]
  63. >>> print(sqlparse.format(first, reindent=True, keyword_case='upper'))
  64. SELECT *
  65. FROM foo;
  66. >>> # Parsing a SQL statement:
  67. >>> parsed = sqlparse.parse('select * from foo')[0]
  68. >>> parsed.tokens
  69. [<DML 'select' at 0x7f22c5e15368>, <Whitespace ' ' at 0x7f22c5e153b0>, <Wildcard '*' … ]
  70. >>>
  71. Pre-commit Hook
  72. ---------------
  73. sqlparse can be used as a `pre-commit <https://pre-commit.com/>`_ hook
  74. to automatically format SQL files before committing:
  75. .. code-block:: yaml
  76. repos:
  77. - repo: https://github.com/andialbrecht/sqlparse
  78. rev: 0.5.4 # Use the latest version
  79. hooks:
  80. - id: sqlformat
  81. # Optional: Add more formatting options
  82. # IMPORTANT: --in-place is required, already included by default
  83. args: [--in-place, --reindent, --keywords, upper]
  84. Then install the hook:
  85. .. code-block:: sh
  86. $ pre-commit install
  87. Your SQL files will now be automatically formatted on each commit.
  88. **Note**: The hook uses ``--in-place --reindent`` by default. If you override
  89. the ``args``, you **must** include ``--in-place`` for the hook to work.
  90. Links
  91. -----
  92. Project page
  93. https://github.com/andialbrecht/sqlparse
  94. Bug tracker
  95. https://github.com/andialbrecht/sqlparse/issues
  96. Documentation
  97. https://sqlparse.readthedocs.io/
  98. Online Demo
  99. https://sqlformat.org/
  100. sqlparse is licensed under the BSD license.
  101. Parts of the code are based on pygments written by Georg Brandl and others.
  102. pygments-Homepage: http://pygments.org/
  103. .. |buildstatus| image:: https://github.com/andialbrecht/sqlparse/actions/workflows/python-app.yml/badge.svg
  104. .. _buildstatus: https://github.com/andialbrecht/sqlparse/actions/workflows/python-app.yml
  105. .. |coverage| image:: https://codecov.io/gh/andialbrecht/sqlparse/branch/master/graph/badge.svg
  106. .. _coverage: https://codecov.io/gh/andialbrecht/sqlparse
  107. .. |docs| image:: https://readthedocs.org/projects/sqlparse/badge/?version=latest
  108. .. _docs: https://sqlparse.readthedocs.io/en/latest/?badge=latest
  109. .. |packageversion| image:: https://img.shields.io/pypi/v/sqlparse?color=%2334D058&label=pypi%20package
  110. .. _packageversion: https://pypi.org/project/sqlparse