#10 Introduction to PostgreSQL: Seeding

Transcript

English (Auto-generated)

So in the last video we learned how to create these two tables in our database. They exist. However we don't have any data or any table rolls inside those tables. So in this video we'll learn how to seed and generate those data into our tables. So we have some information that we can query in the next set of videos. So now let's create a new folder. Gonna call it um seeds. Just to hold our seats. I don't want it to be in the migration folder. I want it to be in a separate folder. So we'll call it seats and we want seats for our students table so let's call it students sq oh we also want a cohort dot SQL because we have a courts student table So then now we would have to go to a terminal. So new terminal already have this installed but in order to get these fake data you would have brew installed that we get. But because I already installed it I'm not gonna reinstall it again. So type is click enter. It's gonna take you guys several minutes to install it. Once you're ready we can type in this command we can save in this. Come on so that we get http. So we already have fake data generated for us and we're just kind of grabbing it from these websites and here we're gonna put it in the seats folder in a file called students Not SQL let's run this first and you'll see that a bunch of information went through because it was downloading the seats. So let's check out our file and the seats dash backslash student S. Q. And see what we have now. So as you can see they actually populated a bunch of information for us. So we don't have to keep typing insert over and over again. Now let's do the same for our cohorts. We will type that the link already auto generated for us and and in the seats folder in a file called cohorts dot SQL will run this. And as you can see it was successful so we'll go back to your cohorts and we have 14 in here And 192 in here or 1 94. So now that we have both of these installed we want to insert into our database. So once more again we're gonna have to go into our database. So postgres issue for users or it's gonna keep using past one. Okay now we're gonna go into our test data ways I shouldn't have colored privilege because it does that make sense now and it's gonna say I successfully connected to it. But let's check out our table. We have a cohorts and student table. So let's see if there's any data and my cohorts table we should not expect to see any because we have not inserted anything into them yet. So now all we have to do using the same syntax import as before. We'll take the folder name seats so I can find the folder um then file name. So as you can see a successfully inserted a bunch of data for us just like we have in here. So let's check it out to see if we do have these data and our cohorts from. So so next Star Star just means to selecting all the column names in our table from cohorts. And as you can see we have a table inside A. We keep clicking enter, we can see all of them. But because I don't have enough space in my terminals compacted and if you want to exit you just have to type cute. So let's continue doing that for our students seeds as well, students that SQL and as you can see we have a bunch of inserts because we have around 1 90 data in our student table. And then now let's do it again. So next start from students and you will see here there's a huge list of information and like clicking enter, we will see all of them. I'm not gonna click all the way to 192 and 94 and Q. Again we're gonna exit. So that's all for the video and the next series of videos, we will finally learn how to query this data because we finally have data in our database
208 Views 0 Likes 0 Comments

In this video you will learn to populate fake data into your database

Comment
Leave a comment (supports markdown format)