Giter Club home page Giter Club logo

django-csv-api-demo's Introduction

django-csv-api-demo

A demonstration project showcasing a Django-based API for uploading and querying CSV files.

Requirements

Before running the project, make sure you have the following components installed:

  • Python 3.12 or later
  • PostgreSQL 14 or later

Setting up the PostgreSQL Database

Ensure that your PostgreSQL database is running and configured. Create a database and user for the project.

Setting Environment Variables

The project uses environment variables for configuration. Create a .env file in the root directory of the project and add the following variables:

SECRET_KEY=your_secret_key
POSTGRES_DB=mydatabase
POSTGRES_USER=myuser
POSTGRES_PASSWORD=mypassword
POSTGRES_HOST=localhost
POSTGRES_PORT=5432

Installing Dependencies

Ensure you have created and activated a Python virtual environment. Then, install the required dependencies:

pip install -r requirements.txt

Applying Migrations

Run the database migrations to create the necessary tables:

python manage.py makemigrations
python manage.py migrate

Running the Project

Start the project with the following command:

python manage.py runserver

Your project should now be available at http://127.0.0.1:8000/.

Using the API

Uploading a CSV File

Make a POST request to http://127.0.0.1:8000/api/upload-csv/ with a JSON body containing the URL to the CSV file and the table name. Optionally, you can specify the overwrite parameter.

{
    "url": "URL_TO_CSV_FILE",
    "table_name": "desired_table_name",
    "overwrite": true
}

Retrieving Data with Filtering

Make a GET request to http://127.0.0.1:8000/api/data/?table=desired_table_name&column1=value1 to retrieve data from the table filtered by column1.

Examples

Examples of how to use the API endpoints can be found in the demo.http file.

django-csv-api-demo's People

Contributors

alexandr0856 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.