|
| 1 | +ObjectBox Python API |
| 2 | +================ |
| 3 | +ObjectBox is a superfast database for objects, now also available for Python. |
| 4 | + |
| 5 | +ObjectBox persists your native Python classes using a simple CRUD API: |
| 6 | + |
| 7 | +```python |
| 8 | +# model.py |
| 9 | +@Entity(id=1, uid=1) |
| 10 | +class Person: |
| 11 | + id = Id(id=1, uid=1001) |
| 12 | + first_name = Property(str, id=2, uid=1002) |
| 13 | + last_name = Property(str, id=3, uid=1003) |
| 14 | + |
| 15 | +# program.py |
| 16 | +box = objectbox.Box(ob, Person) |
| 17 | + |
| 18 | +id = box.put(Person(first_name="Joe", last_name="Green")) # Create |
| 19 | +person = box.get(id) # Read |
| 20 | +person.last_name = "Black" |
| 21 | +box.put(person) # Update |
| 22 | +box.remove(person) # Delete |
| 23 | +``` |
| 24 | + |
| 25 | +For more information and code examples see the tests folder. |
| 26 | + |
| 27 | +Latest release: v0.1.0 |
| 28 | + |
| 29 | +Some features |
| 30 | +------------- |
| 31 | +* automatic transactions (ACID compliant) |
| 32 | +* bulk operations |
| 33 | + |
| 34 | +# Coming soon |
| 35 | +The goodness you know from other language-bindings ObjectBox has, e.g.: |
| 36 | +* model management (no need to manually set id/uid) |
| 37 | +* automatic model migration (no schema upgrade scripts etc.) |
| 38 | +* powerful queries |
| 39 | +* relations (to-one, to-many) |
| 40 | +* asynchronous operations |
| 41 | +* secondary indexes |
| 42 | + |
| 43 | +Installation |
| 44 | +------------ |
| 45 | +To get started with ObjectBox you can get the repository code. |
| 46 | +This repo uses `virtualenv` when installing packages so in case you don't have it yet: `pip install virtualenv`. |
| 47 | + |
| 48 | +The main prerequisite to using the Python APIs is the ObjectBox binary library (.so, .dylib, .dll depending on your platform) which actually implements the database functionality. |
| 49 | +In the [ObjectBox C repository](https://github.com/objectbox/objectbox-c), you should find a download.sh script you can run. |
| 50 | +Follow the instructions and type Y when it asks you if it should install the library. |
| 51 | +```bash |
| 52 | +bash <(curl https://raw.githubusercontent.com/objectbox/objectbox-c/master/download.sh) |
| 53 | +``` |
| 54 | + |
| 55 | +You can run `make test` to make sure everything works as expected. |
| 56 | + |
| 57 | +Required Python version: 3.4+ |
| 58 | + |
| 59 | +License |
| 60 | +------- |
| 61 | + Copyright 2019 ObjectBox Ltd. All rights reserved. |
| 62 | + |
| 63 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 64 | + you may not use this file except in compliance with the License. |
| 65 | + You may obtain a copy of the License at |
| 66 | + |
| 67 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 68 | + |
| 69 | + Unless required by applicable law or agreed to in writing, software |
| 70 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 71 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 72 | + See the License for the specific language governing permissions and |
| 73 | + limitations under the License. |
| 74 | + |
0 commit comments