Skip to content

jpcadena/pydantic-sqlalchemy-tutorial

Repository files navigation

pydantic-sqlalchemy-tutorial


Logo

Pydantic sqlalchemy tutorial

Pydantic sqlalchemy tutorial
Explore the docs »

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

Project

This tutorial provides a comprehensive guide on leveraging the functionalities of Pydantic and SQLAlchemy within Python applications. Pydantic is utilized primarily for data validation and settings management through data parsing and validation using Python type annotations. SQLAlchemy, on the other hand, serves as a powerful SQL toolkit and Object-Relational Mapping (ORM) system for Python, facilitating database communication more efficiently and intuitively.

The aim of this tutorial is to showcase how these two libraries can be integrated to build robust data processing applications. You'll learn how to validate data effectively with Pydantic and perform database operations seamlessly with SQLAlchemy. Whether you're managing data flows for web development with FastAPI or orchestrating complex data transformations for ETL processes, this guide will provide you with the necessary tools and knowledge to enhance your projects' architecture and data integrity.

This guide is ideal for developers looking to improve their backend systems, data scientists seeking to streamline their data handling, and anyone in between who wishes to master these powerful Python libraries.

(back to top)

Built with

Python Pydantic postgresql isort Black Ruff MyPy pre-commit GitHub Actions Poetry Pycharm Visual Studio Code Markdown License: MIT

(back to top)

Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/jpcadena/pydantic-sqlalchemy-tutorial.git
  2. Change the directory to root project

    cd pydantic-sqlalchemy-tutorial
  3. Install Poetry package manager

    pip install poetry
  4. Install the project's dependencies

    poetry install
  5. Activate the environment

    poetry shell

(back to top)

Usage

  1. Setting up environment variables:

    If you find a .env.sample in the project directory, make a copy of it and rename to .env.

    cp .env.sample .env

    This .env file will be used to manage your application's environment variables.

  2. Configuring your credentials:

    Open the .env file in a text editor and replace the placeholder values with your actual credentials.

    # .env file
    POSTGRES_USER=your_database_user
    SECRET_KEY=your_api_key
  3. Execute with console

    python main.py

(back to top)

Contributing

GitHub

Please read our contributing guide for details on our code of conduct, and the process for submitting pull requests to us.

(back to top)

Security

For security considerations and best practices, please refer to our Security Guide for a detailed guide.

(back to top)

Code of Conduct

We enforce a code of conduct for all maintainers and contributors. Please read our Code of Conduct to understand the expectations before making any contributions.

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

  • LinkedIn

  • Outlook

(back to top)