|
| 1 | +# pydantic-sqlalchemy-tutorial |
| 2 | + |
| 3 | +<!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 --> |
| 4 | +<a name="readme-top"></a> |
| 5 | + |
| 6 | +<!-- PROJECT SHIELDS --> |
| 7 | +<!-- |
| 8 | +*** Markdown "reference style" links for readability. |
| 9 | +*** Reference links are enclosed in brackets [ ] instead of parentheses ( ). |
| 10 | +--> |
| 11 | + |
| 12 | + |
| 13 | +<!-- PROJECT LOGO --> |
| 14 | +<br /> |
| 15 | +<div align="center"> |
| 16 | + <a href="https://github.com/othneildrew/Best-README-Template"> |
| 17 | + <img src="assets/images/logo.png" alt="Logo" width="80" height="80"> |
| 18 | + </a> |
| 19 | + |
| 20 | +<h3 align="center">Pydantic sqlalchemy tutorial</h3> |
| 21 | + |
| 22 | + <p align="center"> |
| 23 | + Pydantic sqlalchemy tutorial |
| 24 | + <br /> |
| 25 | + <a href="https://github.com/jpcadena/pydantic-sqlalchemy-tutorial"><strong>Explore the docs »</strong></a> |
| 26 | + <br /> |
| 27 | + </p> |
| 28 | +</div> |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +<!-- TABLE OF CONTENTS --> |
| 33 | +<details> |
| 34 | + <summary>Table of Contents</summary> |
| 35 | + <ol> |
| 36 | + <li> |
| 37 | + <a href="#about-the-project">About The Project</a> |
| 38 | + <ul> |
| 39 | + <li><a href="#built-with">Built With</a></li> |
| 40 | + </ul> |
| 41 | + </li> |
| 42 | + <li> |
| 43 | + <a href="#getting-started">Getting Started</a> |
| 44 | + <ul> |
| 45 | + <li><a href="#prerequisites">Prerequisites</a></li> |
| 46 | + <li><a href="#installation">Installation</a></li> |
| 47 | + </ul> |
| 48 | + </li> |
| 49 | + <li><a href="#usage">Usage</a></li> |
| 50 | + <li><a href="#contributing">Contributing</a></li> |
| 51 | + <li><a href="#license">License</a></li> |
| 52 | + <li><a href="#contact">Contact</a></li> |
| 53 | + </ol> |
| 54 | +</details> |
| 55 | + |
| 56 | + |
| 57 | +<!-- ABOUT THE PROJECT --> |
| 58 | + |
| 59 | +![Project][project-screenshot] |
| 60 | + |
| 61 | +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. |
| 62 | + |
| 63 | +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. |
| 64 | + |
| 65 | + |
| 66 | +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. |
| 67 | + |
| 68 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 69 | + |
| 70 | +### Built with |
| 71 | + |
| 72 | +[![Python][python-shield]][python-url] [![Pydantic][pydantic-shield]][pydantic-url] [![postgresql][postgresql-shield]][postgresql-url] [![isort][isort-shield]][isort-url] [![Black][black-shield]][black-url] [![Ruff][ruff-shield]][ruff-url] [![MyPy][mypy-shield]][mypy-url] [![pre-commit][pre-commit-shield]][pre-commit-url] [![GitHub Actions][github-actions-shield]][github-actions-url] [![Poetry][poetry-shield]][poetry-url] [![Pycharm][pycharm-shield]][pycharm-url] [![Visual Studio Code][visual-studio-code-shield]][visual-studio-code-url] [![Markdown][markdown-shield]][markdown-url] [![License: MIT][license-shield]][license-url] |
| 73 | + |
| 74 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 75 | + |
| 76 | +<!-- GETTING STARTED --> |
| 77 | + |
| 78 | +## Getting Started |
| 79 | + |
| 80 | +### Prerequisites |
| 81 | + |
| 82 | +- [Python 3.12+][python-docs] |
| 83 | + |
| 84 | +### Installation |
| 85 | + |
| 86 | +1. Clone the **repository** |
| 87 | + |
| 88 | + ```bash |
| 89 | + git clone https://github.com/VitaproBI/pydantic-sqlalchemy-tutorial.git |
| 90 | + ``` |
| 91 | + |
| 92 | +2. Change the directory to **root project** |
| 93 | + |
| 94 | + ```bash |
| 95 | + cd pydantic-sqlalchemy-tutorial |
| 96 | + ``` |
| 97 | + |
| 98 | +3. Install **Poetry** package manager |
| 99 | + |
| 100 | + ```bash |
| 101 | + pip install poetry |
| 102 | + ``` |
| 103 | + |
| 104 | +4. Install the project's **dependencies** |
| 105 | + |
| 106 | + ```bash |
| 107 | + poetry install |
| 108 | + ``` |
| 109 | + |
| 110 | +5. Activate the **environment** |
| 111 | + |
| 112 | + ```bash |
| 113 | + poetry shell |
| 114 | + ``` |
| 115 | + |
| 116 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 117 | + |
| 118 | +<!-- USAGE EXAMPLES --> |
| 119 | + |
| 120 | +## Usage |
| 121 | + |
| 122 | +1. **Setting up environment variables:** |
| 123 | + |
| 124 | + If you find a `.env.sample` in the project directory, make a copy of it and rename to `.env`. |
| 125 | + |
| 126 | + ```bash |
| 127 | + cp .env.sample .env |
| 128 | + ``` |
| 129 | + |
| 130 | + This `.env` file will be used to manage your application's environment variables. |
| 131 | + |
| 132 | +2. **Configuring your credentials:** |
| 133 | + |
| 134 | + Open the `.env` file in a text editor and replace the placeholder values with your actual credentials. |
| 135 | + |
| 136 | + ```bash |
| 137 | + # .env file |
| 138 | + POSTGRES_USER=your_database_user |
| 139 | + SECRET_KEY=your_api_key |
| 140 | + ``` |
| 141 | + |
| 142 | +3. Execute with console |
| 143 | + |
| 144 | + ```bash |
| 145 | + python main.py |
| 146 | + ``` |
| 147 | + |
| 148 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 149 | + |
| 150 | +<!-- CONTRIBUTING --> |
| 151 | + |
| 152 | +## Contributing |
| 153 | + |
| 154 | +[![GitHub][github-shield]][github-url] |
| 155 | + |
| 156 | +Please read our [contributing guide](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. |
| 157 | + |
| 158 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 159 | + |
| 160 | +<!-- SECURITY --> |
| 161 | + |
| 162 | +## Security |
| 163 | + |
| 164 | +For security considerations and best practices, please refer to our [Security Guide](SECURITY.md) for a detailed guide. |
| 165 | + |
| 166 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 167 | + |
| 168 | +<!-- CODE_OF_CONDUCT --> |
| 169 | + |
| 170 | +## Code of Conduct |
| 171 | + |
| 172 | +We enforce a code of conduct for all maintainers and contributors. Please read our [Code of Conduct](CODE_OF_CONDUCT.md) to understand the expectations before making any contributions. |
| 173 | + |
| 174 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 175 | + |
| 176 | +<!-- LICENSE --> |
| 177 | + |
| 178 | +## License |
| 179 | + |
| 180 | +Distributed under the MIT License. See [LICENSE](LICENSE) for more information. |
| 181 | + |
| 182 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 183 | + |
| 184 | +<!-- CONTACT --> |
| 185 | + |
| 186 | +## Contact |
| 187 | + |
| 188 | +- [![LinkedIn][linkedin-shield]][linkedin-url] |
| 189 | + |
| 190 | +- [![Outlook ][outlook-shield]](mailto:[email protected]?subject=[GitHub]pydantic-sqlalchemy-tutorial) |
| 191 | + |
| 192 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 193 | + |
| 194 | +<!-- MARKDOWN LINKS & IMAGES --> |
| 195 | +<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --> |
| 196 | + |
| 197 | +[project-screenshot]: assets/images/project.png |
| 198 | +[python-docs]: https://docs.python.org/3.12/ |
| 199 | +[linkedin-shield]: https://img.shields.io/badge/linkedin-%230077B5.svg?style=for-the-badge&logo=linkedin&logoColor=white |
| 200 | +[outlook-shield]: https://img.shields.io/badge/Microsoft_Outlook-0078D4?style=for-the-badge&logo=microsoft-outlook&logoColor=white |
| 201 | +[python-shield]: https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54 |
| 202 | +[pycharm-shield]: https://img.shields.io/badge/PyCharm-21D789?style=for-the-badge&logo=pycharm&logoColor=white |
| 203 | +[markdown-shield]: https://img.shields.io/badge/Markdown-000000?style=for-the-badge&logo=markdown&logoColor=white |
| 204 | +[github-shield]: https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white |
| 205 | +[ruff-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json |
| 206 | +[black-shield]: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge&logo=appveyor |
| 207 | +[mypy-shield]: https://img.shields.io/badge/mypy-checked-2A6DB2.svg?style=for-the-badge&logo=appveyor |
| 208 | +[visual-studio-code-shield]: https://img.shields.io/badge/Visual_Studio_Code-007ACC?style=for-the-badge&logo=visual-studio-code&logoColor=white |
| 209 | +[poetry-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/python-poetry/website/main/static/badge/v0.json |
| 210 | +[isort-shield]: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336 |
| 211 | +[github-actions-shield]: https://img.shields.io/badge/github%20actions-%232671E5.svg?style=for-the-badge&logo=githubactions&logoColor=white |
| 212 | +[pre-commit-shield]: https://img.shields.io/badge/pre--commit-F7B93E?style=for-the-badge&logo=pre-commit&logoColor=white |
| 213 | +[pydantic-shield]: https://img.shields.io/badge/Pydantic-FF43A1?style=for-the-badge&logo=pydantic&logoColor=white |
| 214 | +[postgresql-shield]: https://img.shields.io/badge/PostgreSQL-336791?style=for-the-badge&logo=postgresql&logoColor=white |
| 215 | +[license-shield]: https://img.shields.io/badge/License-MIT-yellow.svg |
| 216 | + |
| 217 | +[linkedin-url]: https://linkedin.com/in/juanpablocadenaaguilar |
| 218 | +[python-url]: https://docs.python.org/3.12/ |
| 219 | +[pycharm-url]: https://www.jetbrains.com/pycharm/ |
| 220 | +[markdown-url]: https://daringfireball.net/projects/markdown/ |
| 221 | +[github-url]: https://github.com/VitaproBI/pydantic-sqlalchemy-tutorial |
| 222 | +[ruff-url]: https://beta.ruff.rs/docs/ |
| 223 | +[black-url]: https://github.com/psf/black |
| 224 | +[mypy-url]: http://mypy-lang.org/ |
| 225 | +[visual-studio-code-url]: https://code.visualstudio.com/ |
| 226 | +[poetry-url]: https://python-poetry.org/ |
| 227 | +[isort-url]: https://pycqa.github.io/isort/ |
| 228 | +[github-actions-url]: https://github.com/features/actions |
| 229 | +[pre-commit-url]: https://pre-commit.com/ |
| 230 | +[pydantic-url]: https://docs.pydantic.dev |
| 231 | +[postgresql-url]: https://www.postgresql.org/ |
| 232 | +[license-url]: https://opensource.org/licenses/MIT |
0 commit comments