Install SQLAlchemy in Python in Windows
This tutorial will explain how to Install SQLAlchemy in Python in Windows.
Q: What is Flask-SQLAlchemy?
Ans:
SQLAlchemy is an ORM library helps convert Python classes/models into database tables and objects into rows and fields. A Flask addon called Flask-SQLAlchemy allows in integrating SQLAlchemy with Flask applications.
Q: What is Flask Python?
Ans:
A Python module that makes it simple to create web applications is called Flask. Its core is compact and simple to extend; it's a microframework that has lots of features, such as url routing and a template engine.
Follow the steps listed below to begin the project:
- Follow the steps to Install Python and editor.
- Create a new virtual environment
- Select Python Interpreter
- Use new virtual environment for the python project
- Activate your new created virtualenv
- Install Flask if not available
We're going to utilize an ORM as it keeps the code much clearer and simpler. Additionally, the ORM library like SQLAlchemy assists us with a number of potential problems while using SQL, including multi-threading support, database migrations and creating default tables according to models etc.
- Use
pip install pymysql
command to install SQLAlchemy into Python project.
PS D:\PythonCrudExample> pip install pymysql
Collecting pymysql
Downloading PyMySQL-1.0.3-py3-none-any.whl (43 kB)
---------------------------------------- 43.7/43.7 kB 2.1 MB/s eta 0:00:00
Installing collected packages: pymysql
Successfully installed pymysql-1.0.3
[notice] A new release of pip is available: 23.0.1 -> 23.1.2
[notice] To update, run: python.exe -m pip install --upgrade pip
Refer Python Flask SQLAlchemy Example to understand and test the database.