Skip to content

siddharth-sundarraman/flask-csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask API for CSV file Uploads

This is a Flask API that allows you to upload a CSV file via POST request and save the contents into a new database table. It uses SQLalchemy for communication with database and pandas to read csv.

Setup

Clone the repository with the following command:

git clone https://github.com/siddharth-sundarraman/flask-csv.git

Initialize virtual environment:

python -m venv venv

Activate virtual environment:

.\venv\Scripts\activate

Install required dependencies:

pip3 install -r requirements.txt

Running the Flask App

python3 run.py

The server will run on http://localhost:5000

Uploading CSV Files

To upload CSV files you can send POST requests using a tool like Postman or curl.

The API endpoint for uploading is

/api/file-import

The CSV will be saved in an sqlite database in the instance/project.db file

Sample post request format:

postman

or curl command:

curl --location --request POST 'http://localhost:5000/api/file-import' \
--form 'files=@"/Users/sid/Downloads/grades.csv"' \
--form 'create_usr_id="sid"' \
--form 'schema="public"'

Viewing tables

Open the SQLite CLI and connect to the database using the command in terminal:

sqlite3 project.db

View tables in database:

sqlite> .tables
output: table_name

View contents of table:

sqlite> SELECT * FROM table_name;

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages