|
| 1 | +# FlyDB-SDK-Python |
| 2 | + |
| 3 | +FlyDB-SDK-Python is a software development toolkit (SDK) for interacting with the FlyDB key-value database in Python. |
| 4 | + |
| 5 | +FlyDB is a high-performance, lightweight key-value database, and with this SDK, you can easily use FlyDB to store and retrieve data in Python. |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +To use FlyDB-SDK-Python, you first need to install the FlyDB server and ensure it is running. |
| 10 | + |
| 11 | +You can install FlyDB-SDK-Python using pip, by running the following command: |
| 12 | + |
| 13 | +``` |
| 14 | +pip install FlyDB-SDK-Python |
| 15 | +``` |
| 16 | + |
| 17 | +## Quick Start |
| 18 | + |
| 19 | +Here's a simple example showing how to use FlyDB-SDK-Python to connect to the FlyDB server and perform data storage and retrieval: |
| 20 | + |
| 21 | +```python |
| 22 | +from pathlib import Path |
| 23 | +from database import db |
| 24 | + |
| 25 | +# Create a database client |
| 26 | +db_client = db.FlyDB() |
| 27 | + |
| 28 | +# Connect to the database |
| 29 | +path = Path.cwd().joinpath("data") |
| 30 | +db_client.connect_option(str(path), 256*1024*1024, True) |
| 31 | + |
| 32 | +# Set a key-value pair |
| 33 | +db_client.set("key", "value", 0) |
| 34 | + |
| 35 | +# Get the value of a key |
| 36 | +value = db_client.get("key") |
| 37 | +print(value) |
| 38 | + |
| 39 | +# Delete a key-value pair |
| 40 | +db_client.delete("key") |
| 41 | +``` |
| 42 | + |
| 43 | +## API ReferenceAPI |
| 44 | + |
| 45 | +FlyDB-SDK-Python currently supports the following APIs: |
| 46 | + |
| 47 | +set(key, value, expire): Stores a key-value pair in the database. The key should be a string, and the value can be a string, integer, float, boolean, or byte stream. The expire parameter represents the expiration time in milliseconds. When expire is set to 0, the data will never expire. |
| 48 | + |
| 49 | +get(key): Retrieves the value of a specified key from the database. The return value type depends on the actual stored data type. |
| 50 | + |
| 51 | +delete(key): Deletes the specified key-value pair from the database. |
| 52 | + |
| 53 | +> For more API reference and detailed usage, please refer to the official documentation or the SDK source code. |
| 54 | +> |
| 55 | +
|
| 56 | +## Contributions and Feedback |
| 57 | + |
| 58 | +If you encounter any issues or have any suggestions, please feel free to raise them. We welcome contributions from the community. If you want to contribute to the FlyDB-SDK-Python project, please submit a Pull Request or contact our development team. |
| 59 | + |
| 60 | +## License |
| 61 | + |
| 62 | +FlyDB-SDK-Python is licensed under the MIT License. For details, please refer to the LICENSE file. |
| 63 | + |
| 64 | +## Disclaimer |
| 65 | + |
| 66 | +FlyDB-SDK-Python is the official Python SDK for the FlyDB project, maintained and supported by the FlyDB team. Thank you for using FlyDB-SDK-Python, and we hope it brings convenience to your data storage and retrieval tasks! |
0 commit comments