You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

METADATA 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Metadata-Version: 2.1
  2. Name: sqlparse
  3. Version: 0.3.0
  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: Topic :: Database
  23. Classifier: Topic :: Software Development
  24. Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
  25. ``sqlparse`` is a non-validating SQL parser module.
  26. It provides support for parsing, splitting and formatting SQL statements.
  27. Visit the `project page <https://github.com/andialbrecht/sqlparse>`_ for
  28. additional information and documentation.
  29. **Example Usage**
  30. Splitting SQL statements::
  31. >>> import sqlparse
  32. >>> sqlparse.split('select * from foo; select * from bar;')
  33. [u'select * from foo; ', u'select * from bar;']
  34. Formatting statements::
  35. >>> sql = 'select * from foo where id in (select id from bar);'
  36. >>> print sqlparse.format(sql, reindent=True, keyword_case='upper')
  37. SELECT *
  38. FROM foo
  39. WHERE id IN
  40. (SELECT id
  41. FROM bar);
  42. Parsing::
  43. >>> sql = 'select * from someschema.mytable where id = 1'
  44. >>> res = sqlparse.parse(sql)
  45. >>> res
  46. (<Statement 'select...' at 0x9ad08ec>,)
  47. >>> stmt = res[0]
  48. >>> str(stmt) # converting it back to unicode
  49. 'select * from someschema.mytable where id = 1'
  50. >>> # This is how the internal representation looks like:
  51. >>> stmt.tokens
  52. (<DML 'select' at 0x9b63c34>,
  53. <Whitespace ' ' at 0x9b63e8c>,
  54. <Operator '*' at 0x9b63e64>,
  55. <Whitespace ' ' at 0x9b63c5c>,
  56. <Keyword 'from' at 0x9b63c84>,
  57. <Whitespace ' ' at 0x9b63cd4>,
  58. <Identifier 'somes...' at 0x9b5c62c>,
  59. <Whitespace ' ' at 0x9b63f04>,
  60. <Where 'where ...' at 0x9b5caac>)