polypheny 0.2.0__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. polypheny-2.0.0/MANIFEST.in +1 -0
  2. {polypheny-0.2.0 → polypheny-2.0.0}/PKG-INFO +63 -43
  3. {polypheny-0.2.0 → polypheny-2.0.0}/README.md +44 -32
  4. polypheny-2.0.0/polypheny/__init__.py +85 -0
  5. polypheny-2.0.0/polypheny/connection.py +327 -0
  6. polypheny-2.0.0/polypheny/exceptions.py +52 -0
  7. polypheny-2.0.0/polypheny/interval.py +37 -0
  8. polypheny-2.0.0/polypheny/rpc.py +236 -0
  9. polypheny-2.0.0/polypheny/serialize.py +126 -0
  10. polypheny-2.0.0/polypheny-connector-version.txt +1 -0
  11. {polypheny-0.2.0 → polypheny-2.0.0}/polypheny.egg-info/PKG-INFO +63 -43
  12. polypheny-2.0.0/polypheny.egg-info/SOURCES.txt +27 -0
  13. polypheny-2.0.0/polypheny.egg-info/requires.txt +1 -0
  14. polypheny-2.0.0/pyproject.toml +3 -0
  15. polypheny-2.0.0/setup.py +82 -0
  16. polypheny-2.0.0/tests/test_conn.py +117 -0
  17. polypheny-2.0.0/tests/test_future.py +37 -0
  18. polypheny-2.0.0/tests/test_helper.py +57 -0
  19. polypheny-2.0.0/tests/test_interval.py +32 -0
  20. polypheny-2.0.0/tests/test_langs.py +28 -0
  21. polypheny-2.0.0/tests/test_mql.py +37 -0
  22. polypheny-2.0.0/tests/test_pep.py +1547 -0
  23. polypheny-2.0.0/tests/test_plain.py +19 -0
  24. polypheny-2.0.0/tests/test_serialize.py +254 -0
  25. polypheny-2.0.0/tests/test_unix.py +37 -0
  26. polypheny-0.2.0/polypheny/__init__.py +0 -66
  27. polypheny-0.2.0/polypheny/auth.py +0 -32
  28. polypheny-0.2.0/polypheny/avatica/__init__.py +0 -1
  29. polypheny-0.2.0/polypheny/avatica/client.py +0 -539
  30. polypheny-0.2.0/polypheny/avatica/protobuf/__init__.py +0 -2
  31. polypheny-0.2.0/polypheny/avatica/protobuf/common_pb2.py +0 -276
  32. polypheny-0.2.0/polypheny/avatica/protobuf/requests_pb2.py +0 -299
  33. polypheny-0.2.0/polypheny/avatica/protobuf/responses_pb2.py +0 -196
  34. polypheny-0.2.0/polypheny/connection.py +0 -158
  35. polypheny-0.2.0/polypheny/cursor.py +0 -353
  36. polypheny-0.2.0/polypheny/environment.py +0 -31
  37. polypheny-0.2.0/polypheny/errors.py +0 -95
  38. polypheny-0.2.0/polypheny/types.py +0 -202
  39. polypheny-0.2.0/polypheny/version.py +0 -3
  40. polypheny-0.2.0/polypheny.egg-info/SOURCES.txt +0 -22
  41. polypheny-0.2.0/polypheny.egg-info/requires.txt +0 -1
  42. polypheny-0.2.0/setup.py +0 -93
  43. {polypheny-0.2.0 → polypheny-2.0.0}/LICENSE +0 -0
  44. {polypheny-0.2.0 → polypheny-2.0.0}/polypheny.egg-info/dependency_links.txt +0 -0
  45. {polypheny-0.2.0 → polypheny-2.0.0}/polypheny.egg-info/top_level.txt +0 -0
  46. {polypheny-0.2.0 → polypheny-2.0.0}/setup.cfg +0 -0
@@ -0,0 +1 @@
1
+ include polypheny-connector-version.txt
@@ -1,35 +1,37 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: polypheny
3
- Version: 0.2.0
4
- Summary: Polypheny Connector for Python
5
- Home-page: https://polypheny.org/
3
+ Version: 2.0.0
4
+ Summary: Driver for Polypheny
5
+ Home-page: https://polypheny.com/
6
6
  Author: The Polypheny Project
7
7
  Author-email: mail@polypheny.org
8
8
  License: Apache License, Version 2.0
9
- Project-URL: Documentation, https://polypheny.org/documentation/
9
+ Project-URL: Documentation, https://docs.polypheny.com/en/latest/drivers/python/overview
10
10
  Project-URL: Code, https://github.com/polypheny/Polypheny-Connector-Python
11
11
  Project-URL: Issue tracker, https://github.com/polypheny/Polypheny-DB/labels/A-python
12
- Platform: UNKNOWN
13
- Classifier: Programming Language :: Python :: 3.6
14
- Requires-Python: >=3.6
12
+ Requires-Python: >=3.9
15
13
  Description-Content-Type: text/markdown
16
14
  License-File: LICENSE
17
-
18
- <!--<p align="center">
19
- <picture>
20
- <source
21
- srcset="https://raw.githubusercontent.com/polypheny/Admin/master/Logo/logo-white-text.png"
22
- media="(prefers-color-scheme: dark)">
23
- <a href="https://polypheny.org/">
24
- <img align="center" width="300" height="300" src="https://raw.githubusercontent.com/polypheny/Admin/master/Logo/logo-transparent.png">
25
- </a>
26
- </picture>
27
- </p>
28
- -->
29
-
30
- <a href="https://polypheny.org/">
31
- <img align="right" width="300" height="300" src="https://raw.githubusercontent.com/polypheny/Admin/master/Logo/logo-transparent.png" alt="Resume application project app icon">
32
- </a>
15
+ Requires-Dist: polypheny-prism-api==2.2
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license
22
+ Dynamic: license-file
23
+ Dynamic: project-url
24
+ Dynamic: requires-dist
25
+ Dynamic: requires-python
26
+ Dynamic: summary
27
+
28
+ <p align="center">
29
+ <a href="https://polypheny.org/">
30
+ <picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/polypheny/Admin/master/Logo/logo-white-text_cropped.png">
31
+ <img width='50%' alt="Light: 'Resume application project app icon' Dark: 'Resume application project app icon'" src="https://raw.githubusercontent.com/polypheny/Admin/master/Logo/logo-transparent_cropped.png">
32
+ </picture>
33
+ </a>
34
+ </p>
33
35
 
34
36
 
35
37
  # Polypheny Connector for Python
@@ -37,7 +39,7 @@ License-File: LICENSE
37
39
  This enables Python programs to access Polypheny databases, using an API that is compliant with the [Python Database API Specification v2.0 (PEP 249)](https://www.python.org/dev/peps/pep-0249/).
38
40
 
39
41
 
40
- ### Installation
42
+ ## Installation
41
43
 
42
44
  The recommended way to install the Python Connector for Polypheny is via pip:
43
45
  ```bash
@@ -50,6 +52,9 @@ cd /path/to/polyphney-connector-python-x.y.z/
50
52
  python setup.py install
51
53
  ```
52
54
 
55
+ The connector uses the Prism 2.2 client definitions and connects to servers
56
+ that report a compatible Prism 2.x API. The minor versions do not have to match.
57
+ Document collection metadata requires server-side support introduced in Prism 2.2.
53
58
 
54
59
 
55
60
  ## Getting Started
@@ -57,33 +62,57 @@ python setup.py install
57
62
  A few examples of the most common functionalities provided by the adapter:
58
63
 
59
64
 
60
- ```python
65
+ ```python3
61
66
  import polypheny
62
67
 
63
- # Connect to Polypheny
64
- connection = polypheny.connect('localhost', 20591, user='pa', password='')
68
+ # Connect to locally running Polypheny via UNIX sockets (on Linux, BSD and macOS)
69
+ con = polypheny.connect()
70
+
71
+ # Unencrypted over the network (all systems)
72
+ con = polypheny.connect(
73
+ ('127.0.0.1', 20590),
74
+ username='pa',
75
+ password='',
76
+ transport='plain',
77
+ )
65
78
 
66
79
  # Get a cursor
67
- cursor = connection.cursor()
80
+ cursor = con.cursor()
68
81
 
69
82
  # Create a new table
70
83
  cursor.execute("CREATE TABLE dummy (id INT NOT NULL, text VARCHAR(2), num INT, PRIMARY KEY(id))")
71
84
 
72
85
  # Insert values into table
73
86
  cursor.execute("INSERT INTO dummy VALUES (407 , 'de', 93)")
74
- connection.commit()
87
+ con.commit()
75
88
 
76
89
  # Execute a query
77
90
  cursor.execute("SELECT * from dummy")
78
- result = cursor.fetchall()
91
+
92
+ print("\nRelational results from SQL")
93
+ for row in cursor:
94
+ print("\t", row)
95
+
96
+ # Accessing data using MQL
97
+ cursor.executeany('mongo', 'db.dummy.find()', namespace='public')
98
+
99
+ print("\nDocument results from MQL (as Python dicts)")
100
+ for doc in cursor:
101
+ print("\t", doc)
102
+
103
+ cursor.execute("DROP TABLE dummy")
79
104
 
80
105
  # Close the connection
81
- connection.close()
106
+ con.close()
82
107
  ```
83
108
 
84
- An in-depth and more detailed documentation can be found [here]()
85
-
109
+ An in-depth and more detailed documentation can be found [here](https://docs.polypheny.com/en/latest/drivers/python/overview).
86
110
 
111
+ ## Tests
112
+ Run the tests with coverage report:
113
+ ```
114
+ coverage run --source polypheny -m pytest && coverage report -m
115
+ ```
87
116
 
88
117
  ## Roadmap
89
118
  See the [open issues](https://github.com/polypheny/Polypheny-DB/labels/A-python) for a list of proposed features (and known issues).
@@ -95,14 +124,5 @@ We highly welcome your contributions to the _Polypheny Connector for Python_. If
95
124
  Please note that we have a [code of conduct](https://github.com/polypheny/Admin/blob/master/CODE_OF_CONDUCT.md). Please follow it in all your interactions with the project.
96
125
 
97
126
 
98
- ## Credits
99
- This work was influenced by the following projects:
100
-
101
- * [python-phoenixdb](https://github.com/lalinsky/python-phoenixdb)
102
- * [snowflake-connector-python](https://github.com/snowflakedb/snowflake-connector-python)
103
-
104
-
105
127
  ## License
106
128
  The Apache 2.0 License
107
-
108
-
@@ -1,18 +1,10 @@
1
- <!--<p align="center">
2
- <picture>
3
- <source
4
- srcset="https://raw.githubusercontent.com/polypheny/Admin/master/Logo/logo-white-text.png"
5
- media="(prefers-color-scheme: dark)">
6
- <a href="https://polypheny.org/">
7
- <img align="center" width="300" height="300" src="https://raw.githubusercontent.com/polypheny/Admin/master/Logo/logo-transparent.png">
8
- </a>
9
- </picture>
10
- </p>
11
- -->
12
-
13
- <a href="https://polypheny.org/">
14
- <img align="right" width="300" height="300" src="https://raw.githubusercontent.com/polypheny/Admin/master/Logo/logo-transparent.png" alt="Resume application project app icon">
15
- </a>
1
+ <p align="center">
2
+ <a href="https://polypheny.org/">
3
+ <picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/polypheny/Admin/master/Logo/logo-white-text_cropped.png">
4
+ <img width='50%' alt="Light: 'Resume application project app icon' Dark: 'Resume application project app icon'" src="https://raw.githubusercontent.com/polypheny/Admin/master/Logo/logo-transparent_cropped.png">
5
+ </picture>
6
+ </a>
7
+ </p>
16
8
 
17
9
 
18
10
  # Polypheny Connector for Python
@@ -20,7 +12,7 @@
20
12
  This enables Python programs to access Polypheny databases, using an API that is compliant with the [Python Database API Specification v2.0 (PEP 249)](https://www.python.org/dev/peps/pep-0249/).
21
13
 
22
14
 
23
- ### Installation
15
+ ## Installation
24
16
 
25
17
  The recommended way to install the Python Connector for Polypheny is via pip:
26
18
  ```bash
@@ -33,6 +25,9 @@ cd /path/to/polyphney-connector-python-x.y.z/
33
25
  python setup.py install
34
26
  ```
35
27
 
28
+ The connector uses the Prism 2.2 client definitions and connects to servers
29
+ that report a compatible Prism 2.x API. The minor versions do not have to match.
30
+ Document collection metadata requires server-side support introduced in Prism 2.2.
36
31
 
37
32
 
38
33
  ## Getting Started
@@ -40,33 +35,57 @@ python setup.py install
40
35
  A few examples of the most common functionalities provided by the adapter:
41
36
 
42
37
 
43
- ```python
38
+ ```python3
44
39
  import polypheny
45
40
 
46
- # Connect to Polypheny
47
- connection = polypheny.connect('localhost', 20591, user='pa', password='')
41
+ # Connect to locally running Polypheny via UNIX sockets (on Linux, BSD and macOS)
42
+ con = polypheny.connect()
43
+
44
+ # Unencrypted over the network (all systems)
45
+ con = polypheny.connect(
46
+ ('127.0.0.1', 20590),
47
+ username='pa',
48
+ password='',
49
+ transport='plain',
50
+ )
48
51
 
49
52
  # Get a cursor
50
- cursor = connection.cursor()
53
+ cursor = con.cursor()
51
54
 
52
55
  # Create a new table
53
56
  cursor.execute("CREATE TABLE dummy (id INT NOT NULL, text VARCHAR(2), num INT, PRIMARY KEY(id))")
54
57
 
55
58
  # Insert values into table
56
59
  cursor.execute("INSERT INTO dummy VALUES (407 , 'de', 93)")
57
- connection.commit()
60
+ con.commit()
58
61
 
59
62
  # Execute a query
60
63
  cursor.execute("SELECT * from dummy")
61
- result = cursor.fetchall()
64
+
65
+ print("\nRelational results from SQL")
66
+ for row in cursor:
67
+ print("\t", row)
68
+
69
+ # Accessing data using MQL
70
+ cursor.executeany('mongo', 'db.dummy.find()', namespace='public')
71
+
72
+ print("\nDocument results from MQL (as Python dicts)")
73
+ for doc in cursor:
74
+ print("\t", doc)
75
+
76
+ cursor.execute("DROP TABLE dummy")
62
77
 
63
78
  # Close the connection
64
- connection.close()
79
+ con.close()
65
80
  ```
66
81
 
67
- An in-depth and more detailed documentation can be found [here]()
68
-
82
+ An in-depth and more detailed documentation can be found [here](https://docs.polypheny.com/en/latest/drivers/python/overview).
69
83
 
84
+ ## Tests
85
+ Run the tests with coverage report:
86
+ ```
87
+ coverage run --source polypheny -m pytest && coverage report -m
88
+ ```
70
89
 
71
90
  ## Roadmap
72
91
  See the [open issues](https://github.com/polypheny/Polypheny-DB/labels/A-python) for a list of proposed features (and known issues).
@@ -78,12 +97,5 @@ We highly welcome your contributions to the _Polypheny Connector for Python_. If
78
97
  Please note that we have a [code of conduct](https://github.com/polypheny/Admin/blob/master/CODE_OF_CONDUCT.md). Please follow it in all your interactions with the project.
79
98
 
80
99
 
81
- ## Credits
82
- This work was influenced by the following projects:
83
-
84
- * [python-phoenixdb](https://github.com/lalinsky/python-phoenixdb)
85
- * [snowflake-connector-python](https://github.com/snowflakedb/snowflake-connector-python)
86
-
87
-
88
100
  ## License
89
101
  The Apache 2.0 License
@@ -0,0 +1,85 @@
1
+ # Copyright 2024 The Polypheny Project
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from polypheny.connection import Connection, Cursor
16
+ from polypheny.exceptions import *
17
+
18
+ import datetime
19
+ from typing import Union
20
+
21
+ # See https://peps.python.org/pep-0249/#globals
22
+ apilevel = '2.0'
23
+ threadsafety = 0
24
+ paramstyle = 'qmark'
25
+
26
+
27
+ def Date(year, month, day):
28
+ return datetime.date(year, month, day)
29
+
30
+
31
+ def Time(hour, minute, second):
32
+ return datetime.time(hour, minute, second)
33
+
34
+
35
+ def Timestamp(year, month, day, hour, minute, second):
36
+ return datetime.datetime(year, month, day, hour, minute, second)
37
+
38
+
39
+ # See PEP 249
40
+ import time
41
+
42
+
43
+ def DateFromTicks(ticks):
44
+ return Date(*time.localtime(ticks)[:3]) # TODO: Really local time?
45
+
46
+
47
+ def TimeFromTicks(ticks):
48
+ return Time(*time.localtime(ticks)[3:6])
49
+
50
+
51
+ def TimestampFromTicks(ticks):
52
+ return Timestamp(*time.localtime(ticks)[:6])
53
+
54
+
55
+ def Binary(string):
56
+ return string.encode('UTF-8')
57
+
58
+
59
+ # Intentionally omitted, we always give type_code = None, like sqlite3
60
+ # STRING = 1
61
+ # BINARY = 2
62
+ # NUMBER = 3
63
+ # DATETIME = 4
64
+ # ROWID = 5
65
+
66
+
67
+ def connect(address: Union[tuple[str, int], str] = None, *, username: str = None, password: str = None,
68
+ transport: str = None, **kwargs) -> Connection:
69
+ """
70
+ Connect to a Polypheny instance with the given parameters. When
71
+ no parameters are given, the driver will connect via the ``unix``
72
+ transport to ``~/.polypheny/polypheny-prism.sock``.
73
+
74
+ :param address: A :py:class:`str` for ``unix`` transport or a (hostname, port) :py:class:`tuple` for ``plain`` transport.
75
+ :param username: username
76
+ :param password: password
77
+ :param transport: Either ``plain`` or ``unix``
78
+
79
+ """
80
+ if address is None and transport is None and username is None and password is None and len(kwargs) == 0:
81
+ transport = 'unix'
82
+ elif address is None or transport is None:
83
+ raise Error("Address and transport must be given")
84
+
85
+ return Connection(address, username, password, transport, kwargs)