Step-by-Step Guide to Using HarperDB with Django:
- Install HarperDB Package: Install the HarperDB Python package using pip to connect to the database and make queries.
- Connect to Database: In the Django project's settings.py file, import HarperDB and create a connection to your HarperDB instance using the provided URL, username, and password.
- Query Database: Access data in your views by importing the DB variable from settings.py and making queries directly. For example, retrieve developers with a specific attribute from the 'hackathon' schema and 'developers' table using the search_by_value method.
- Adding CRUD Functionality:a. Return Single Item: Fetch a single developer's profile from the database using the search_by_hash method.b. Creating Items: Add a new developer profile to the database using the insert method when handling a POST request from a form.c. Updating Items: Update a developer's profile in the database using the update method when handling a POST request from a form.d. Deleting Items: Delete a developer's profile from the database using the delete method when handling a POST request from a form.
With these steps, you can effectively use HarperDB in your Django application to perform CRUD operations and interact with your database.