August 18, 2022

Using HarperDB With Django

Welcome to Community Posts
Click below to read the full article.
Summary of What to Expect
Table of Contents

Step-by-Step Guide to Using HarperDB with Django:

  1. Install HarperDB Package: Install the HarperDB Python package using pip to connect to the database and make queries.
  2. 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.
  3. 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.
  4. 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.