Skip to content

TaLevy5/DataSaver

Repository files navigation

SaveDataAPI

A simple RESTful API built with Flask that allows saving user data into a SQL Server database using pyodbc.

Features

  • Exposes a POST endpoint /SaveData to store data.
  • Accepts firstName and lastName as JSON payload.
  • Connects to SQL Server database via pyodbc.
  • Includes error handling and clear response messages.
  • Runs locally with Flask, easy to extend for production.

Tech Stack

  • Python 3
  • Flask
  • SQL Server
  • pyodbc

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/SaveDataAPI.git
    cd SaveDataAPI
  2. Create a virtual environment and install dependencies:

    python -m venv venv
    source venv/bin/activate   # On Windows: venv\Scripts\activate
    pip install -r requirements.txt
  3. Update database connection string in app.py:

    connection_string = "DRIVER={ODBC Driver 17 for SQL Server};SERVER=localhost;DATABASE=yourDB;UID=yourUser;PWD=yourPassword"
  4. Run the server:

    flask run

Usage

Send a POST request to /SaveData with JSON body:

{
  "firstName": "John",
  "lastName": "Doe"
}

Example with curl:

curl -X POST http://127.0.0.1:5000/SaveData \\
  -H "Content-Type: application/json" \\
  -d '{"firstName": "John", "lastName": "Doe"}'

Example response:

{
  "status": "success",
  "message": "Data saved successfully!"
}

Project Structure

.
├── app.py              # Main Flask application
├── requirements.txt    # Python dependencies
└── README.md           # Project documentation

Future Improvements

  • Add GET endpoints to fetch saved data.
  • Add authentication & authorization.
  • Containerize with Docker.
  • Deploy on cloud (AWS / Azure).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages