LearnSQLAlchemy Basics

Treehouse
writes on February 15, 2021

Today we released “SQLAlchemy Basics,” a new course from Treehouse instructorMegan 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:

Install SQLAlchemy with VSCode

是多少平方LAlchemy

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:

  1. Create a virtual environmentby running `python -m venv env`. If you’re on a Mac, you may need to type this command out as `python3 -m venv env`.
  2. Activate your environmentby running `.\env\Scripts\activate`if you’re on Windows or `source ./env/bin/activate` if you’re on a Mac.
  3. Install SQLAlchemywith `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`.
  4. 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.

(Follow along with a screencast of these steps here.)

Learn SQLAlchemy with Treehouse

SQLAlchemy Basicsincludes video instruction, code challenges, quizzes, and more. You can take the Treehouse course for free with a seven day free trial. Then, dive into morePythonorSQLcontent 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 yourfree seven day trial.

What sets Treehouse apart is their dedication to helping you find your perfect job or develop your own business. –SwitchUp.org

Follow us onTwitter,Instagram, andFacebookfor our favorite tips, and to share how your learning is going. We’ll see you there!

If you liked reading this article, you should also look at these two:

Leave a Reply

You must belogged into post a comment.

Want to learn more about Python?

Learn the general purpose programming language Python and you will be able to build applications and tools.

了解更多