Today we released “SQLAlchemy Basics,” a new course from Treehouse instructor Megan Amendola. The 190 minute Python course will teach you how to: Create a database model, interact with a database using CRUD (create, read, update, and delete), and use queries to access specific information.
In this article, you’ll learn:
SQLAlchemy is an “ORM” or object-relational mapper. It’s a Python code library that transfers data stored in a SQL database into Python objects. You can then use Python code to create, read, update, and delete data instead of writing straight SQL, which helps speed up development time, especially for developers who are not fluent in SQL. And it can often make managing data less error-prone.
If you’re not familiar with SQL, take a peek at the prerequisites for this course:
How to download SQLAlchemy
We’ll need to download SQLAlchemy so we can use it. Here are the steps:
- Create a virtual environment by running `python -m venv env`. If you’re on a Mac, you may need to type this command out as `python3 -m venv env`.
- Activate your environment by running `.\env\Scripts\activate` if you’re on Windows or `source ./env/bin/activate` if you’re on a Mac.
- Install SQLAlchemy with `pip install sqlalchemy`. To make sure it’s been added to our project, we can create our requirements.txt file since we have just installed a project requirement. Run `pip freeze > requirements.txt`.
- If you want to post this on GitHub, create a .gitignore file. Inside write env to ignore this folder. Others will only need the requirements file to download the right packages and start your project.
Master SQLAlchemy with Treehouse
SQLAlchemy Basics includes video instruction, code challenges, quizzes, and more. You can take the Treehouse course for free with a seven day free trial. Then, dive into more Python or SQL content with your Treehouse subscription.
Related Treehouse Tracks for beginners:
Learning with Treehouse starts at only $19.99 per month. If you think you’re ready to start exploring if tech is right for you, sign up for your free seven day trial.
What sets Treehouse apart is their dedication to helping you find your perfect job or develop your own business. – SwitchUp.org
If you liked reading this article, you should also look at these two:
- The Best Places to Look for Your First Tech Job
- 5 Treehouse Students Who Found Tech Jobs in Less than a Year