From the course: Building RESTful APIs with Flask

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Setting up SQLAlchemy

Setting up SQLAlchemy

From the course: Building RESTful APIs with Flask

Start my 1-month free trial

Setting up SQLAlchemy

- [Instructor] Back in PyCharm, we've got the libraries installed, but before we can actually use them we have to do a few configuration steps first. So the first thing I'm going to do is to go back into my code and scroll all the way to the top, and I'm going to add a couple of import statements here. The first one is from flask_sqlalchemy import SQLAlchemy, and the next one is from sqlalchemy import Column, Integer, String, and Float. These are all types that we're going to be needing here in just a few minutes. And then the other thing that I'm going to need is the operating system library, so I'll do import os, and that should do it for my imports. The next step is to add the configuration. So since this is a file-based database, I need to tell my application where to store the file. So go right below where you created the app there on line seven, and let's add something to this very quickly. I'm going to add a variable called basedir, base directory, and I'm going to set it to…

Contents