PKG-INFO 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. Metadata-Version: 2.1
  2. Name: phoenixdb
  3. Version: 1.1.0
  4. Summary: Phoenix database adapter for Python
  5. Home-page: http://phoenix.apache.org/python.html
  6. Author: Apache Software Foundation
  7. Author-email: dev@phoenix.apache.org
  8. License: Apache 2
  9. Description: Phoenix database adapter for Python
  10. ===================================
  11. ``phoenixdb`` is a Python library for accessing
  12. `Apache Phoenix <http://phoenix.apache.org/>`_
  13. using the
  14. `remote query server <http://phoenix.apache.org/server.html>`_.
  15. This library implements the
  16. standard `DB API 2.0 <https://www.python.org/dev/peps/pep-0249/>`_ interface and a
  17. subset of `SQLAlchemy <https://www.sqlalchemy.org/>`_, either of which should be familiar
  18. to most Python programmers.
  19. Installation
  20. ------------
  21. The source code is part of the phoenix-queryserver source distribution.
  22. You can download it from <https://phoenix.apache.org/>, or get the latest development version
  23. from <https://github.com/apache/phoenix-queryserver>
  24. Extract the archive and then install it manually::
  25. cd /path/to/phoenix-queryserver-x.y.z/python/phoenixdb
  26. python setup.py install
  27. Usage
  28. -----
  29. The library implements the standard DB API 2.0 interface, so it can be
  30. used the same way you would use any other SQL database from Python, for example::
  31. import phoenixdb
  32. import phoenixdb.cursor
  33. database_url = 'http://localhost:8765/'
  34. conn = phoenixdb.connect(database_url, autocommit=True)
  35. cursor = conn.cursor()
  36. cursor.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username VARCHAR)")
  37. cursor.execute("UPSERT INTO users VALUES (?, ?)", (1, 'admin'))
  38. cursor.execute("SELECT * FROM users")
  39. print(cursor.fetchall())
  40. cursor = conn.cursor(cursor_factory=phoenixdb.cursor.DictCursor)
  41. cursor.execute("SELECT * FROM users WHERE id=1")
  42. print(cursor.fetchone()['USERNAME'])
  43. Setting up a development environment
  44. ------------------------------------
  45. If you want to quickly try out the included examples, you can set up a
  46. local `virtualenv <https://virtualenv.pypa.io/en/latest/>`_ with all the
  47. necessary requirements::
  48. virtualenv e
  49. source e/bin/activate
  50. pip install -r requirements.txt
  51. python setup.py develop
  52. You can start a Phoenix QueryServer instance on http://localhost:8765 for testing by running
  53. the following command in the pohoenix-queryserver-parent directory::
  54. mvn clean verify -am -pl phoenix-queryserver-it -Dtest=foo \
  55. -Dit.test=QueryServerBasicsIT\#startLocalPQS \
  56. -Ddo.not.randomize.pqs.port=true -Dstart.unsecure.pqs=true
  57. You can start a secure (https+kerberos) Phoenix QueryServer instance on https://localhost:8765
  58. for testing by running the following command in the phoenix-queryserver-parent directory::
  59. mvn clean verify -am -pl phoenix-queryserver-it -Dtest=foo \
  60. -Dit.test=SecureQueryServerPhoenixDBIT\#startLocalPQS \
  61. -Ddo.not.randomize.pqs.port=true -Dstart.secure.pqs=true
  62. this will also create a shell script in phoenix-queryserver-it/target/krb_setup.sh, that you can use to set
  63. up the environment for the tests.
  64. If you want to use the library without installing the phoenixdb library, you can use
  65. the `PYTHONPATH` environment variable to point to the library directly::
  66. cd phoenix-queryserver-parent/python-phoenixdb
  67. python setup.py build
  68. cd ~/my_project
  69. PYTHONPATH=$PHOENIX_HOME/build/lib python my_app.py
  70. Don't forget to run flake8 on your changes.
  71. Running the test suite
  72. ----------------------
  73. The library comes with a test suite for testing Python DB API 2.0 compliance and
  74. various Phoenix-specific features. In order to run the test suite, you need a
  75. working Phoenix database and set the ``PHOENIXDB_TEST_DB_URL`` environment variable::
  76. export PHOENIXDB_TEST_DB_URL='http://localhost:8765/'
  77. nosetests
  78. If you use a secure PQS server, you can set the connection parameters via the following environment
  79. variables:
  80. - PHOENIXDB_TEST_DB_TRUSTSTORE
  81. - PHOENIXDB_TEST_DB_AUTHENTICATION
  82. - PHOENIXDB_TEST_DB_AVATICA_USER
  83. - PHOENIXDB_TEST_DB_AVATICA_PASSWORD
  84. Similarly, tox can be used to run the test suite against multiple Python versions::
  85. pyenv install 3.5.5
  86. pyenv install 3.6.4
  87. pyenv install 2.7.14
  88. pyenv global 2.7.14 3.5.5 3.6.4
  89. PHOENIXDB_TEST_DB_URL='http://localhost:8765' tox
  90. You can use tox and docker to run the tests on supported python versions up to 3.8 without
  91. installing the environments locally::
  92. docker build -t toxtest .
  93. docker run --rm -v `pwd`:/src toxtest
  94. You can also run the test suite from maven as part of the Java build by setting the
  95. run.full.python.testsuite property. You DO NOT need to set the PHOENIXDB_* enviroment variables,
  96. maven will set them up for you. The output of the test run will be saved in
  97. phoenix-queryserver/phoenix-queryserver-it/target/python-stdout.log and python-stderr.log::
  98. mvn clean verify -Drun.full.python.testsuite=true
  99. Known issues
  100. ------------
  101. - TIME and DATE columns in Phoenix are stored as full timestamps with a millisecond accuracy,
  102. but the remote protocol only exposes the time (hour/minute/second) or date (year/month/day)
  103. parts of the columns. (`CALCITE-797 <https://issues.apache.org/jira/browse/CALCITE-797>`_, `CALCITE-798 <https://issues.apache.org/jira/browse/CALCITE-798>`_)
  104. - TIMESTAMP columns in Phoenix are stored with a nanosecond accuracy, but the remote protocol truncates them to milliseconds. (`CALCITE-796 <https://issues.apache.org/jira/browse/CALCITE-796>`_)
  105. SQLAlchemy feature support
  106. --------------------------
  107. SQLAlchemy has a wide breadth of API, ranging from basic SQL commands to object-relational mapping support.
  108. Today, python-phoenixdb only supports the following subset of the complete SQLAlchemy API:
  109. - `Textual SQL <https://docs.sqlalchemy.org/en/13/core/tutorial.html#using-textual-sql>`_
  110. All other API should be considered not implemented.
  111. Platform: UNKNOWN
  112. Classifier: Programming Language :: Python
  113. Classifier: Programming Language :: Python :: 2
  114. Classifier: Programming Language :: Python :: 2.7
  115. Classifier: Programming Language :: Python :: 3
  116. Classifier: Programming Language :: Python :: 3.4
  117. Classifier: Programming Language :: Python :: 3.5
  118. Classifier: Programming Language :: Python :: 3.6
  119. Classifier: Programming Language :: Python :: 3.7
  120. Classifier: Programming Language :: Python :: 3.8
  121. Provides-Extra: SQLAlchemy