1
1
ObjectBox Python API
2
2
====================
3
+
3
4
ObjectBox is a superfast database for objects, now also available for Python with a simple CRUD API.
4
5
5
6
* Python version: 3.4+
6
- * Platforms supported:
7
- * Linux 64-bit
8
- * Linux ARMv6hf (e.g. Raspberry PI Zero)
9
- * Linux ARMv7hf (e.g. Raspberry PI 3)
10
- * MacOS 64-bit
11
- * Windows 64-bit
7
+ * Platforms supported:
8
+ * Linux x86-64 (64-bit)
9
+ * Linux ARMv6hf (e.g. Raspberry PI Zero)
10
+ * Linux ARMv7hf (e.g. Raspberry PI 3)
11
+ * MacOS x86-64 (64-bit)
12
+ * MacOS arm64 (Apple silicon)
13
+ * Windows x86-64 (64-bit)
12
14
13
15
Getting started
14
16
---------------
17
+
15
18
First of all, install the latest version:
19
+
16
20
``` bash
17
21
pip install --upgrade objectbox
18
22
```
19
23
20
- To start using ObjectBox as a storage for your data, you need to define your model first.
21
- The model consists of Python classes annotated with ` @Entity ` decorator.
24
+ To start using ObjectBox as a storage for your data, you need to define your model first.
25
+ The model consists of Python classes annotated with ` @Entity ` decorator.
22
26
23
27
### Model IDs and UIDs
24
- Each Entity has to have an ID (unique among entities).
25
- Properties need an ID as well (unique inside one Entity).
28
+
29
+ Each Entity has to have an ID (unique among entities).
30
+ Properties need an ID as well (unique inside one Entity).
26
31
Both Entities and Properties must also have an UID, which is a globally unique identifier.
27
32
28
33
For other ObjectBox supported languages, the binding takes care of assigning these IDs/UIDs but this feature is not yet implemented for Python.
29
- To learn more, see ObjectBox Java documentation: https://docs.objectbox.io/advanced/meta-model-ids-and-uids
34
+ To learn more, see [ ObjectBox Java documentation] ( https://docs.objectbox.io/advanced/meta-model-ids-and-uids )
30
35
31
36
#### model.py
37
+
32
38
``` python
33
39
from objectbox.model import *
34
40
@@ -40,10 +46,12 @@ class Person:
40
46
```
41
47
42
48
### Using ObjectBox
49
+
43
50
To actually use the database, you launch (or "build") it with the model you've just defined.
44
51
Afterwards, you can reuse the instance (` ob ` in the example below) and use it to access "Entity Boxes" which hold your objects.
45
-
52
+
46
53
#### program.py
54
+
47
55
``` python
48
56
import objectbox
49
57
# from mypackage.model import Person
@@ -56,7 +64,7 @@ ob = objectbox.Builder().model(model).directory("db").build()
56
64
57
65
# Open the box of "Person" entity. This can be called many times but you can also pass the variable around
58
66
box = objectbox.Box(ob, Person)
59
-
67
+
60
68
id = box.put(Person(first_name = " Joe" , last_name = " Green" )) # Create
61
69
person = box.get(id ) # Read
62
70
person.last_name = " Black"
@@ -75,11 +83,13 @@ For more information and code examples, see the tests folder. The docs for other
75
83
76
84
Some features
77
85
-------------
86
+
78
87
* automatic transactions (ACID compliant)
79
88
* bulk operations
80
89
81
90
Coming in the future
82
91
--------------------
92
+
83
93
The goodness you know from the other ObjectBox language-bindings, e.g.,
84
94
85
95
* model management (no need to manually set id/uid)
@@ -91,29 +101,33 @@ The goodness you know from the other ObjectBox language-bindings, e.g.,
91
101
92
102
Help wanted
93
103
-----------
94
- ObjectBox for Python is still in an early stage with limited feature set (compared to other languages).
95
- To bring all these features to Python, we're asking the community to help out. PRs are more than welcome!
96
- The ObjectBox team will try its best to guide you and answer questions.
104
+
105
+ ObjectBox for Python is still in an early stage with limited feature set (compared to other languages).
106
+ To bring all these features to Python, we're asking the community to help out. PRs are more than welcome!
107
+ The ObjectBox team will try its best to guide you and answer questions.
97
108
See [ CONTRIBUTING.md] ( https://github.com/objectbox/objectbox-python/blob/main/CONTRIBUTING.md ) to get started.
98
109
99
110
Feedback
100
111
--------
101
- Also, please let us know your feedback by opening an issue: for example, if you experience errors or if you have ideas
112
+
113
+ Also, please let us know your feedback by opening an issue: for example, if you experience errors or if you have ideas
102
114
for how to improve the API. Thanks!
103
115
104
116
License
105
117
-------
106
- Copyright 2019-2020 ObjectBox Ltd. All rights reserved.
107
-
108
- Licensed under the Apache License, Version 2.0 (the "License");
109
- you may not use this file except in compliance with the License.
110
- You may obtain a copy of the License at
111
-
112
- http://www.apache.org/licenses/LICENSE-2.0
113
-
114
- Unless required by applicable law or agreed to in writing, software
115
- distributed under the License is distributed on an "AS IS" BASIS,
116
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
117
- See the License for the specific language governing permissions and
118
- limitations under the License.
119
118
119
+ ``` text
120
+ Copyright 2019-2021 ObjectBox Ltd. All rights reserved.
121
+
122
+ Licensed under the Apache License, Version 2.0 (the "License");
123
+ you may not use this file except in compliance with the License.
124
+ You may obtain a copy of the License at
125
+
126
+ http://www.apache.org/licenses/LICENSE-2.0
127
+
128
+ Unless required by applicable law or agreed to in writing, software
129
+ distributed under the License is distributed on an "AS IS" BASIS,
130
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131
+ See the License for the specific language governing permissions and
132
+ limitations under the License.
133
+ ```
0 commit comments