![]() I know we haven't really talked about the type of application we're going to build out, mainly because you can build anything that you want in this particular project. I'm going to start off with this, and I'm going to call OS, our operating system library, and then say:īasedir = os.path.abspath(os.path.dirname(_file_))Īpp.config = 'sqlite:///' + os.path.join(basedir, 'app.sqlite') This is going to stand for the base directory of our application because if we don't know what the base directory is then flask isn't going to know where to save our SQLite table to. I'm going to start off by creating a variable here called basedir. In order to do that, if you remember back on line 4, we imported the OS library which stands for operating system. So we need to be able to save our database to our project. The next thing we're going to do is we're going to integrate with the file system. We're going to be building now our own API endpoint, so let's just remove that just so it doesn't get in the way. Now the first thing I'm going to do is, we don't need this basic app route or anything like that here anymore. That means we are going to define the table that we want to work with, and then we are going to allow that code to generate the table for us. That's what we do in this guide and we're going to create what is called a schema. Instead, we're going to be able to simply create a file that will function exactly like how a database would. It's what's called an embedded database, and that means that we're going to be able to not have to worry about setting up an entire development environment for a database like we would have to do with my SQL or Postgres. We're going to use what is called SQLite. We are not going to use mySQL or anything like Oracle. What we're going to do is we're going to programmatically create a database table, and we're going to use a pretty basic database. ![]() Simply look at this as a high-level type of understanding, and try to have that for building out what we're going to do here. Don't worry about understanding everything that we're going to talk about. What my recommendation would be to follow along and see what gets built out. Now in this guide, what we're going to do, and just be prepared, this one is going to be a little longer and it's also going to be a little bit complicated if you've never done it before.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |