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.
- polypheny-2.0.0/MANIFEST.in +1 -0
- {polypheny-0.2.0 → polypheny-2.0.0}/PKG-INFO +63 -43
- {polypheny-0.2.0 → polypheny-2.0.0}/README.md +44 -32
- polypheny-2.0.0/polypheny/__init__.py +85 -0
- polypheny-2.0.0/polypheny/connection.py +327 -0
- polypheny-2.0.0/polypheny/exceptions.py +52 -0
- polypheny-2.0.0/polypheny/interval.py +37 -0
- polypheny-2.0.0/polypheny/rpc.py +236 -0
- polypheny-2.0.0/polypheny/serialize.py +126 -0
- polypheny-2.0.0/polypheny-connector-version.txt +1 -0
- {polypheny-0.2.0 → polypheny-2.0.0}/polypheny.egg-info/PKG-INFO +63 -43
- polypheny-2.0.0/polypheny.egg-info/SOURCES.txt +27 -0
- polypheny-2.0.0/polypheny.egg-info/requires.txt +1 -0
- polypheny-2.0.0/pyproject.toml +3 -0
- polypheny-2.0.0/setup.py +82 -0
- polypheny-2.0.0/tests/test_conn.py +117 -0
- polypheny-2.0.0/tests/test_future.py +37 -0
- polypheny-2.0.0/tests/test_helper.py +57 -0
- polypheny-2.0.0/tests/test_interval.py +32 -0
- polypheny-2.0.0/tests/test_langs.py +28 -0
- polypheny-2.0.0/tests/test_mql.py +37 -0
- polypheny-2.0.0/tests/test_pep.py +1547 -0
- polypheny-2.0.0/tests/test_plain.py +19 -0
- polypheny-2.0.0/tests/test_serialize.py +254 -0
- polypheny-2.0.0/tests/test_unix.py +37 -0
- polypheny-0.2.0/polypheny/__init__.py +0 -66
- polypheny-0.2.0/polypheny/auth.py +0 -32
- polypheny-0.2.0/polypheny/avatica/__init__.py +0 -1
- polypheny-0.2.0/polypheny/avatica/client.py +0 -539
- polypheny-0.2.0/polypheny/avatica/protobuf/__init__.py +0 -2
- polypheny-0.2.0/polypheny/avatica/protobuf/common_pb2.py +0 -276
- polypheny-0.2.0/polypheny/avatica/protobuf/requests_pb2.py +0 -299
- polypheny-0.2.0/polypheny/avatica/protobuf/responses_pb2.py +0 -196
- polypheny-0.2.0/polypheny/connection.py +0 -158
- polypheny-0.2.0/polypheny/cursor.py +0 -353
- polypheny-0.2.0/polypheny/environment.py +0 -31
- polypheny-0.2.0/polypheny/errors.py +0 -95
- polypheny-0.2.0/polypheny/types.py +0 -202
- polypheny-0.2.0/polypheny/version.py +0 -3
- polypheny-0.2.0/polypheny.egg-info/SOURCES.txt +0 -22
- polypheny-0.2.0/polypheny.egg-info/requires.txt +0 -1
- polypheny-0.2.0/setup.py +0 -93
- {polypheny-0.2.0 → polypheny-2.0.0}/LICENSE +0 -0
- {polypheny-0.2.0 → polypheny-2.0.0}/polypheny.egg-info/dependency_links.txt +0 -0
- {polypheny-0.2.0 → polypheny-2.0.0}/polypheny.egg-info/top_level.txt +0 -0
- {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
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: polypheny
|
|
3
|
-
Version:
|
|
4
|
-
Summary:
|
|
5
|
-
Home-page: https://polypheny.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
65
|
+
```python3
|
|
61
66
|
import polypheny
|
|
62
67
|
|
|
63
|
-
# Connect to Polypheny
|
|
64
|
-
|
|
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 =
|
|
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
|
-
|
|
87
|
+
con.commit()
|
|
75
88
|
|
|
76
89
|
# Execute a query
|
|
77
90
|
cursor.execute("SELECT * from dummy")
|
|
78
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
38
|
+
```python3
|
|
44
39
|
import polypheny
|
|
45
40
|
|
|
46
|
-
# Connect to Polypheny
|
|
47
|
-
|
|
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 =
|
|
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
|
-
|
|
60
|
+
con.commit()
|
|
58
61
|
|
|
59
62
|
# Execute a query
|
|
60
63
|
cursor.execute("SELECT * from dummy")
|
|
61
|
-
|
|
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
|
-
|
|
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)
|