SQL with Python in 90 minutes | Max S | Skillshare

SQL with Python in 90 minutes

Max S, Power through programming

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
10 Lessons (1h 24m)
    • 1. Course Intro

      0:56
    • 2. SQL Introduction

      8:16
    • 3. Creating And Connecting To A Database

      10:09
    • 4. Navigating a Database

      9:06
    • 5. Creating and Removing Tables

      10:22
    • 6. Inserting Data

      13:52
    • 7. Getting Data

      14:01
    • 8. Conditional Searching of Data

      7:05
    • 9. Updating and Deleting Data

      9:06
    • 10. Course Outro

      0:50
17 students are watching this class

About This Class

Python is one of the most friendly and popular programming languages. It finds applications everywhere, ranging from research, over to industry, as well as things like the entertainment industry. Programming in general allows for you to greatly reduce workload, as well as solve problems that would be impossible to solve by hand, or create great, new, and fun applications/software.

A big part of the new digital world is that everything is producing data, and storing as well as using data are becoming emerging and very important industry fields. The ability to combine data usage with programming allows for rapid development and automation, and is extremely superior when compared to systems that need manual input or data handling.

SQL is the language that you can use to interact with one major database type (SQL databases), one that is very wide-spread in today's world. 

Knowing SQL will give you a nice ability and understanding of how to handle data and databases, and being able to integrate it into Python code enables you to create great, dynamic, and automatic systems that combine the power of programming and data.

This course will be using SQLite in Python, which allows us to execute SQL commands through python, and will allow you to create, connect, use, and manage local SQL-based databases. 

Transcripts

1. Course Intro: everyone, It's Max. And welcome to my course SQL on Python in 90 minutes. Now, this course has made for beginner to intermediate level. So anyone who has some basic python probing experience, we don't need to have any previous SQL knowledge. In this course, you're gonna learn the basics of using SQL and you also gonna learn how to use SQL and Python so that you can directly integrated into your coat. You're gonna learn how to create and connect to a local SQL database. You're gonna learn how to insert your data, extract your data update and delete your data from your database, and you're also gonna learn about conditional ways to retrieve your data. Now, by the end of this course, you're gonna be able to write python or SQL code to create and insert data into your database to update and delete data in your database and also to extract data using conditional statements 2. SQL Introduction: Heffron, It's Max and welcome to my SQL course for Python. We're going to be using sq light, which is a library made for a price in Does allows us to use SQL within Python. All right, so let's get started. And first of all, talk about what? Even our databases. Well, you can imagine databases to be kind of like your banks, but for data rather than for money. And just like in banks where you can make deposits for money and databases, you can also deposit your data. Similarly, you can also withdraw data, although not like banks. Where one you withdraw money, you lose the money so it's no longer in your account. If you withdraw from the database, it's still going to be there. But you're kind of withdrawing a copy of it on. And then you can also do things like updating databases and kind of managing them and stuff so kind of like the mawr upper level things that you can also do with your bank account. Now databases have their ordered and they're structured, and that's why I used them. And they have, you know, general, things like rows and columns like you know from CSC tables, but they also contain just general tables, like I just mentioned so, like, for, you know, like an excel table or something like that, if you want to imagine it. But I can also be, you know, much bigger. It can have many, many different directions that you can go into as well a some information about these tables and some mawr linking information. And so that's where this order and structure comes in is that you want to make sure that everything is in the right place and that you can reference whatever it is that you need. Um, so let's compare databases and tables a little bit, So if we look at tables tables they used for one specific project So maybe you're doing, you know, Big Science Project, and you have a table in all of that table stores, all of the data that you're using for your science projects. So you're gonna have different columns that show, you know, the different features. So maybe your measuring like temperature, distant time, all of these things. So each column is going to say, Hey, this is my temperature, you know, this is my time everything in this car is going to time. Everything in this column was going to be distanced, you know, it's and so on. And then you've got a rose. In each of these rows displays a specific measuring point, so each row would be an instance where you measure temperature where you measure time were you measure distance or whatever else you're measuring. And that row kind of relates all of the features at that certain point in time, and it should be simultaneous. That should be as close as possible. So really, what you get from a row is that all of your data for each of those features is the data at that point. So they're all related. It's like a sample now. Databases. On the other hand, they are. You can think of them like a collection of tables, so you can also have single tables and call them a database if he want. But a database can really be much bigger, and it can contain all of these selections table so that you don't just have you're, you know, science, fair, project table or science fair project data. But really you have your whole high school and college science data in a database. And then you can have your high school section, and then you can have your science fair in your college and your Year one and specific labs . You know, those can also all be different parts of the database. But you can all even all store all of that data into this bigger database. Andan. So this database, of course, also has some attributes that describe the information so that it's easy for you to say, Hey, I want to get, you know, the specific values. But I want to make sure I get them from my first year in college when I measured them were or something like that. All right, so what exactly is SQL Vin? Well, ehskyoo stands for a structure career language. But really, what it does is it enables us to interact with the database, and you can kind of think of it like a programming language. So the programming language that we use in this kids would be python and that allows us to interact with the computer. It allows us, you know, to tell the computer to do things, whereas SQL it allows us to interact with the database and then we say, Hey, you know, database. I want this and it it's this means of communication It's the language that the database speaks and so that's what SQL is now. An important thing to note is that SQL has different data types. So, like in python, you know, well, actually, in python we have different data types like integers and floating point number strings bulletins. We've seen all of them and so those are the types of data that we encounter in python and of course, there are many more, but those are just kind of the basic examples. But in SQL, we can also have data types that describe our data. And so these would be or there are five main types which is no. So we just got a no value and then we've got integers, which we know from integers from python real numbers, which we know is floating point numbers. So these decimal numbers, then we've got text until in Texas, if you actually put in some text, it gets converted to a you to a utf format. So either utf eight or one of the U tria beauty F 16 formats, and then you've got something called a blob and blob is really just The data that you put in is exactly the data that's stored, so it's not changed in any way. It's exactly what you put in. That's exactly what stored. And so the reason that you care about these different data types is because different data types have different sizes, and so you want to make sure also when you're creating or when you putting in data that you give the right data type, and so it depends on what you use. But integers, for example, could take up a lot less space than real numbers and stuff with them. But it's also important because when you interact with the data, you want to know or it be easier if you're, you know if you call them is described as introduced that all the values that you get out, you know, to be or introduce, and rather than if you just say text, then it could be that you may not know what to expect because there could be some text values in there. So also, you know, these data types again are great for you because it allows you to give, or it gives you this better, higher up understanding if your data All right, so how would we install this, or how would we go about this? Well, what's really cool is that SQL It actually comes with python. So if you have piping installed, um, sq lights already there and you're ready to go If you don't have Python, you can go to python dot org's and just download the newest version there. So we're currently using 3.6. But if you just hover over the downloads tab, it would just, you know, give you the 2.7 versions or something like that and then give you the newest three point version. I would recommend using the newest three point or, if there is four point later or something else. I would recommend using that just because it's the newest version and you just kind of wanna stay up to date. And there's a reason that the versions are newer. There's buck fixes. You know there's improvements. They just make your life easier. So it's nicer to stay with the newer versions. Um, if you want to look at the dog Devi file. So the database files that we create in this tutorial. Then you can head over to sq light browser dot org's and you can just download it. And then that's pretty much it allows you to open these dot db file. So, like a text editing application allows you to open like dot txt files and word allows you to open word documents. Now all these things the sq like browser would allow you to open these dot db files. 3. Creating And Connecting To A Database: everyone, it's Max and welcome back. So in this tutorial, we're going to start off and talk about how we can create as well as connect toward database. So we'll see how we can create a first database, and then we'll move on to doing stuff with it later. All right, so the first thing that we're gonna need to do is we're gonna need to need to import sq light. And since I'm using python 3.6, I'm gonna import secu light three like this. And so this is kind of the standard module that should come with Python. And you could just import it like we talked about in the mosque. Tutorial on this will give you all of those features thought we can, you know, use to interact with databases using SQL. All right, so let's create our first database. Um And so the way that will create a first database is we're going to be going into sq light three, and here we're gonna be executing the connect method. And so you can imagine it's very similar to opening a file on Python. Where and python, we would say if you want to open a file. We would go like, open, and then we would give in here the path to our file. And then we can also optionally give, read or write, or something like that. And so for creating a database, it's very similar in here. We'll just put the name of our database. So, for example, call this one our training database and will give it the extension dot db to indicate that it actually is a database. All right, so this is how we connect to a database pretty much open a database, and we need to save that in a variable. So just like when we create a file will stay about in a very both so that we can access this file. We're going to save our database and a variable, and we can just call that Khan for now, short for connect, which is kind of the standard training name that you give it. And so what we've done here is we've used the method connect, which is contained instead of this sq light three module that were imported here, and we're connecting to this training database now. If the database doesn't exist, it would just create the file similar to if we or it would create the database. Similar to if we open a file and we use this right, um, command or this right feature. So if the file doesn't exist, then we would just create the file. Otherwise, we would start overriding in. And so here we connect to the database. If it exists, grace and will continue, you know, doing stuff with that. Otherwise, if it doesn't exist, then it would just created for us. Okay, so now we've got this database. The next thing that we're gonna need is we're gonna need something to go through the database. Something you know, that kind of tells us where we are right now. So we've got this database connection, but we need to be able to move our way through it. And the way we do that is using something called a cursor. And so to get a cursor will save it in a variable. We'll just call it C, which is gonna be short for cursor here, and we're gonna go into our connection. So up here, the variable that connects us to our database and we're going to call, um, this cursor method And so, um, we're gonna initialize a cursor here or probably were actually a class rather than a method . But we're gonna initialize this cursor here. And so this cursor is what we have in this Very well. See, that's what's gonna allow us to navigate through a database. And so again, kind of going back to files. If you have a little bit more experience with navigating files, the way that it really works is that if you have some text in a file so something like this , you know, you've got some text in the file and if you read the file, you can actually go through it kind of bit by bit here. And so you'd read one character at a time. And the character that you're at right now, that's kind of where your cursor for the file is pointing them. And you can change the location if you want to re read from some things using this seek method, for example, and so for a database, it would be very similar. We use the cursor to navigate through a database that kind of indicates where we are right now, So that's the principle of this cursor. Okay, so now that we have this database set up and we've got this connection the state of this connection, we've got this cursor that we can use to navigate through it. Let's actually go ahead and do something. So the way that we do something in the databases that we would use an execute command or the execute method, Um, that's contained inside of a cursor like this. And so this is how we can do stuff generally, um, to the database and so again relating to files. This would be very similar to doing something like F dot Right. So here, for example, we would write to the file or F dot read or something like that. And so here it's a very similar but more broad, um, feature where the execute just allows us to execute the command, which is whatever we put in here. So we'll grant we're gonna put in a command in here a strength and that's what it's gonna execute and the Christer is gonna executed, and it's gonna executed on this database that we've connected to, so we'll go over a lot of the commands later on, but I'll just show you a sample thing that you can do on DSO we're gonna create a table. And if you're writing SQL commands even in Python, you want to keep it in all caps and this is gonna help with readability and stuff so that you know which of these are your SQL commands? And so that's why for for writing in SQL code here, we're gonna be writing in all caps. So, for example, create a table we're gonna write, creates table. And so these are key words that you know are known for SQL So these air keywords and SQL But we're gonna actually upended a little bit and add some logic and, you know, don't worry about this is just an example. I just wanted to show you how this execute command works, But we're gonna have some logic and we're, say, create the table if not exist. So if the table doesn't exist, then we're gonna create it, and then we're gonna put some parameters in here. So we're going to give the table name, for example. We can call it Ice Cube melting, which would represent maybe a sign experiment that we're doing where we have an Ice Cube in a water bath and the escape is melting and we're just measuring the temperature of the water and stuff like that and keeping track of it. And so what we're doing here right now is we're creating a table if it doesn't exist, the table name is ice cubes melting. And we just need to define the parameters now that are inside of this table. And we do that by opening, closing the parentheses behind the table name. And so the first parameter that our letter table will have where the first column name, Let's call that or let's have that be the time. So, um, are calling Name is gonna be time here and now we also need to pass to it a type. And so in this case, maybe let's have it be an integer if you remember from last lecture, we talked about the different data types that are possible in ehskyoo. So in this case, we would say that the time is an integer and we say that the time is an integer because we leave a space here and if you want to create our next column, for example, we would just do a comma here and then if you want, maybe we can go on to a new line by kind of adding a plus year like this and so will go into a new line. And what to it? So you've got the time here, which is an integer. The next thing we would like is maybe the temperature, which is going to be a real number. So we've got that riel data type here and then lastly, if we want, we can add a date, and the state is just gonna be a text value on Baby. We want this because some days it's hotter. Some days it's colder. You know, humidity changes all of these things if we want to compare over different dates. And so that's really what we're doing with this is we're creating a table that when the tables called ice cubes melting and it has three columns, it has time temperature in date and time containing integer values. Temperature is gonna contain real numbers, and date is going to contain text values. All right, so that's what we can do. Um, with this execute command. So pretty much what we're doing is we're executing the command that we've put in here and again. We'll go over the structure later on. This is just more about what this execute statement does. Once we've executed something, the next thing that we want to do is we want to kind of update or savor database. And so the way that we do that is we would use something called commit. And so we can go into our connection to our database here, and we just call the commit method, which kind of updates everything. And you know, it says yes, I want to save it. And you know all of these things. Um, and that makes it available for everyone else connecting to the database. Um, yeah. And then lastly, what we need to do is similar to files us. We need to close everything. So we'll start off closing the cursor and then what clothes? The connection to her database like this. And this kind of de allocates the memory, freeze everything up so that we can use memory and Aram again for other things. Right? So this is the basic structure. Let's save and run this to make sure that it works. And so we see, everything kind of went through. It seemed to work. Um, and if you just navigate, you know, through your folders, wherever it is that you're saving it. So, for example, I'm just, you know, kind of saving it in my home folder into a folder that I called sq light. And if you go there, then you should find a new file called training Doc db. Um, yeah, and that's where we've saved our database in. And so it for you continue on later in this course that we're going to continue connecting to this database and we just continue changing. Changing things will continue adding to it, maybe taking some things out, reading it all of these things. 4. Navigating a Database: everyone, it's Max and welcome back. So in this tutorial, we're gonna look a little bit about how we can navigate a database. So what we've seen before is how we can connect or create a database and kind of understand what a cursor is as well as how we can use this execute method to execute SQL commands. And then we used, commit to kind of update our database and finally be closed all of our connections. It's gonna leave this here so that we can reference it. Um, but I'm going to take some of the stuff away. So since we've already created our database and we've already created a table, we don't need to execute it again. We can execute this command again if we want to, because we're just creating the table if it doesn't exist. But I'll just leave it commented out. The only thing is I'm going to keep is I'm gonna keep my connection to this database so I don't have to write it again. We just want to deal with the same database, and I'm also going to keep the cursor that I set up here, and I'll just leave the closing the Christian closing the connection here at the very end that I don't forget to do it. Um, yeah. So let's look at how we can navigate a database. And so what we're gonna do is we're gonna start off and we're gonna use the execute command as a basis. And what we're gonna do here is we're gonna run in a query and we'll get into queries later on on. We'll just again uses as an example just like we did these SQL statement here where we created a table. We just uses an example. Get back into that to show what the execute method here does. But what we're going to do here is we're going to run a query through the table that we've created together some data on, and then we're gonna look at the different methods about, you know, getting certain amount of data. Um, So what we're gonna execute here is we're just gonna execute something called a see select query. And so we're doing here is we're selecting. We're going to select specific columns or all of the columns from a specific table so that we can get data back from it. So For example, we've got our time column in this ice cube melting table so it can say is select time from Ice Cube melting. So this is the table name that I've created, or the name of the table that I've previously created, or the name of the table that I won't select from. I want to select the tying column from it on gun. I'm gonna execute this SQL query. So again, don't worry about this stuff. Too much will go go over this again later. Really, What we're interested in is the things that follow this. So now that we've run this query, so this is kind of similar to, you know, preparing to read from a file. We're not exactly reading it, but we're kind of we're gathering the data on DNA now. What we're gonna do is we're going to go through it. So what we've done here, basically is we've kind of opened up again. We're like this, too, on files. We've kind of opened up our database in reading mode, so it's ready to read, and we have the data available to us now. We just need to go through it. And so what we can do am if we use files again, We can say, you know, f dot read line. If I opened my file and reading mode here and this will read the first line and we can do something very similar, um, here, using our database so we can go into our cursor and we can say and fetch one. And so what this is going to do is it's gonna fetch the first result from our query. And if we want, we can save up in the variable call that result if we like and we can print out the results . And so what this gives us is this either gives us a sequence. I said, what we get back here. I'm so a row with all of the appropriate table, all the appropriate column values from the table that we put in a year or give us a nolle valley if there's no data available. So since we haven't actually put in any data into our table, we're gonna get a no value back. But I think it's important to kind of talk about the different methods that we can go through things. So when we start putting in data when we start reading data, we know how to use these methods rather than having to go through them then and kind of interrupt in the middle. So if I just save and run, this we see here is I get none. So I get nothing returned. So I've executed a query, and I want to say, Hey, you know, select some data from the ice cubes melting table. I want to look at the time column, Um and then here I want to get the first row of data. Well, we didn't actually put anything into this. Ice keeps melting table yet, so the data that we're gonna get returned is just gonna be nothing there. There is no data there. And so that's what we see here. We see none. That's that's what we get returned if there is no more available data, and so we can also print out the result here. Um, the next thing that we can do is and will just say this in a result again. So here we fetched one. If you want a fetch several rows at once, we can also do such money and others a default size here, which is actually the array size of a cursor which, if you want you can maybe, except for you can access it like this. But you can print it out like this to see what the array sizes. But you can also put in your own kind of special size a few months. So let's say you wanted to fetch the next five rows that we can define the size to be five and we can print out the result again now similar to what we've done but fear. So if you don't actually have any data remaining, we're going to get an empty list. Otherwise we're going to get a list. I'm containing as much more up to five rows. So what we did here is we were we would fetch the first Rome. Then we would print the first roll off course. We only have the Time column. Then we would fetch the remaining five rows available for the next five rose if there are only four rows remaining. So we've read the 1st 1 and we are five in total. So then there's four remaining who would only get four here if there is no remaining roast , which is what we have here. So we don't have any results, and we want to fetch results again. We're going to get an empty list. If there are more than five remaining, we would just get five. So if we save and from this we would see first we get the none returned from our fetch one , and then we would get the empty list return from or fetch many simply because we don't have any date on this tale. You. And so we'll go through this later when we actually, you know, input data when we actually go through and try to read the data on. But it's just important to know the different ways that we can go through on re data. All right, so we've got the fetch one. We've got the fetch. Many. The last thing that we're gonna do is we're going to do something called a fetch. Aw, which is related to files again, something like this. So here we would read the entire file, or at least the remaining part of the file. So if you read the first line of the file already than we would just read everything after our first line. So everything after where cursor is. And so you would do the same thing with the fetch all command like this. And here we would just fetch the remaining rose. So let's say we have 10 rows and total here we fetched one. So now we're on road to he re fetch another five. So now we fetch six rows. And so, hero, fetch the remaining. So that would be seven till the end. And so that's what we would get from here. So again very similar to files and or curse or kind of keeps track where we are in the database right now and where in the table we are right now. And here we can print out the result. And again, the result He was going to be returned to us as a list. So all of the data will be elements in the list if there's data, Otherwise, it's just gonna be an empty list like we also get from the fetch money. So we see here, we've got the nun because we have no data and we do the fetch one, which is what's returned here. We've got the empty list which comes from this. Fetch many command and we've got the another anti list which comes from this fetch all But these are the different ways that we can use to kind of navigate through our database and gather data from it. And you'll see this actually be quite nice to use once we start inserting data and then when we use queries like the select quarry to go through our tables and maybe only specific columns if you want, or all of the columns s so that we can read all of that data. 5. Creating and Removing Tables: everyone, It's Max. And welcome back in this tutorial, we're gonna go over creating as well as removing tables. Now, something that you may have noticed before we start is that I've moved my training database into a folder called Data Bases. And this is just kind of for organizational purposes for myself. But we're gonna go over this, see, don't execute command so that we used from this cursor and were first gonna look at the general structure of how we can create tables. And then we'll review what we did over here and hopefully get a better understanding of this. And then finally, we also look at how we can drop or remove tables. All right, so let's talk about the general structure of creating tables first, um or rather the general syntax. So if you want to create a table, um, first, you're gonna have to write the kind of key statement create table. And this year, dis usually put into your c dot execute like we did below. Um, and once you put this and put this in, then you're gonna define your table name here, and then you're gonna open and closed parentheses like this um, and inside here, you're going to put the parameter of the table. So you're gonna have your column names. So here we can have, for example, column one name, and then we're gonna have the associate ID data type to this column one then we can put in a comma And what is going to the next line here? And we can put in a second column if we like. So putting in the call in to name and then the associated data type of calling to and so on until we have, um, our last column and the associative data type like this. And so that's how you congee generally create a table on Go on non end. Also here again, we after close parentheses so that we get this one closed. So we've got the 1% sees that comes after the table name. We can, you know, define the column names as well. It's the associated data type. And then we've got the other parentheses to kind of close out this on cursed her. Don't execute a method that we're using here. All right, so that's the general structure. There is one more thing that we can do namely weaken. Define which of these columns is something called a primary key. So if we have a column name here Andan, we've got the associative data type of that column. Um, we can choose one column toe. I kind of have br primary column. And what this means is that no value in there is gonna be repeated. And so it's pretty much uniquely gonna identify all of the values in our table on the way that I can create this primary key is after I have my column, um, name in my data type for it, which is separated by spaces. As you can see here, I'm gonna put a space. I mean, type in the keywords Primary key and capital just like this. So this doesn't need to be replaced by anything This data type, you're going to kind of fill into the four different Tater Tot data types that we cover before here. You can just choose an appropriate column name. So down here with time, for example. But here I'm after the data type you're gonna put into their space, and then you're gonna type in primary space key, and that's going to identify that this column is the primary key for your table. Now what does that mean? Well, let's kind of think of an example. So if you're creating a table that keeps track of employees, your primary key could, for example, be the employee I. D. So every employee gets its own unique I d. And to identify each employee, you just use the employee i d. And from there you can get all of the information about, you know, the employees and their the employee. I D Numbers are not gonna be repeated. They're all unique, and so that's very important. Every value in the primary key column needs to be unique, and it's not allowed to be known. But the idea is that every value in that column can uniquely identify whatever that row kind of represents or whatever that slice of data represents. So if we go back down here into our si dot execute statement and so he rewrite treat table and we've added in a little bit of logic, eso were saying, if not exists, and so this is very similar to the python logic eso were saying, if not is a kind of normal private statement and we'll exists. Um, as the name suggests, if it doesn't exist, then we do the following. And so there are different types of logic that you can use. I think for creating tables is probably the most common one or probably only one that you'll really need, because you just don't want to create repeat tables or something like that over right thumb . So if you want to prevent those things, you could just add this if not exists in here. And then we've got our table name as we've specified up here. And then we start, you know, defining your columns and their data types. And so, after table name, we open parentheses and we closed them right here. And so our first column it's called Time and that's data type is an interview. And our second column is the temperature, which is a real number, and the third column is the date. Who's data type is text. So right now we see that we don't have a primary key. If we want, we can actually make time our primary key. But we can only do this if we don't repeat the experiment. So if we only, really. The experiment run once than every point in time that we measure is always gonna be unique . So we're going to start at zero, and we're just gonna keep measuring time and time and temperature is gonna change. But temperature doesn't have to be unique. So if we've got a rice keep melting, it could be that at the end we settle at some kind of constant temperature. And so our temperatures kind of going to settle our date is going to be constant. So for performing this experiment on one day, our date is gonna be constant. But our time can be unique now. It doesn't have to be, because if we repeat this experiment several times, we're probably gonna have the same time Interval. So have you know a time that zero minutes a time that it's that's at one minute. So depending on, um, if you how many times you do this experiment or maybe you create a new table for every experiment every time you do the experiment, But depending on that, you could make your time, the primary he when she would do it like this, so we would literally just right in a primary key after it like that. But again, you don't need to. And so to kind of get that a bit more organized. Well, close the string here will put a plus and we'll put this on the new line and then we'll open. I will start a new spring here and now we can actually pull all of this onto the same line to, um this is just for our structure. So what this is doing is just contaminating the string. But we see that we've got this primary key value here, But again, you only want to use the primary key. If you know your time values, we're gonna unique. So let's leave it in there for now. Let's save it and then let's run. And so we've executed our statement. I'm actually going to go into the databases folder here and let's take a look at our training database and so we can open it. And I'm using this sq like browser that I talked about earlier. And you can see here we've created we have a table in here. What's called ice keeps nothing. And if we go into browse data, we see we have this Time column. We've got his temperature column, and we've also got this date call here, which is exactly what leave Specified. Um, right over here. We don't have any data in there yet, which is, you know, kind of makes sense because we haven't put anything inside. But we see that we've got this table created in our database, which is what we have here. All right, so let me close this. So that's how we go about creating databases. Um, so how would we remove database while to remove a database? We're gonna use the syntax or start to remove a table. We're going to use the syntax called drop table. So we've got the create table over here, which has all of this format to drop the table. We just write drop table, and then we write the table name, and that's it. We don't need to specify anything else and so executed or to execute. The SQL command will once again go into a cursor going to this execute method and pass a string the drop table command and will pass the table name, which we can just copy from here and paste in there and so we want to drop the table ice, keep melting. And really, what this does is it removes the table. It removes all information associated with it. All of the data contained inside. You know, this is a delete table method, so you should really only want drop the table if you know you don't want to use it anymore . If you move the data somewhere else, then you can drop the table from your database. If you feel like you're still gonna need it, you probably don't want to drop it, especially not without backing it up. Because once you drop it, once you delete it, the data is gone. So that's important to remember. But if you do want to remove it, this is how you do it so we can save and run. And if we go into our training database again here and open it now, we've got no tables, and it's because our table has been deleted. All right, so that's how we go about creating and removing tables in our database. 6. Inserting Data: Hey, everyone, it's Max End. Welcome back. So now that we know how to create as well has dropped tables, let's go and look at how it can insert data into tables. So I'm just gonna continue on where we left off last time. But I'll take away some of these comments and I'll actually take away this drop table, um, command as well. And so really, what we're just gonna do is we're gonna create our table. Um, if it doesn't exist, and we'll just create the table that we made before, All right, So let's talk about how we can insert data in to our table. Well, the general syntax is going to be, um we're gonna use a insert into command, and then we're gonna have our table name, and then we're gonna have this values keyword here. And so really, what we're gonna do is we're gonna insert into our table the following values, and then we can open and close parentheses like this, and for each of her columns, we can have an appropriate value. So we'll have. In this case, we have three columns, so it would have, for example, that one, two and value three like this. So we've got three appropriate values for each of her columns. If we have more columns, we can, of course, put in more values in here. And so this would be the one way that we kind of manually insert data if we wanted into a database. So let's go ahead and try that out. And again. Of course, we have to execute command, and we'll put this industry and well, right in here. Insert into our table name. I'm just gonna copy, paste it over to make sure everything is good. It's gonna be ice cube melting and into it will insert the values M. And then I'll put a plus here so I can continue this on the next line and in open and closed parentheses, just like I do here, um, and put a space in front here. All right. So the values that I'm gonna put in here, let's just try these out on The first thing I wanna put in here is I mean, put in the time. So I have beaten energy weaken, just maybe have that be zero. Our temperature is gonna be a real number. And let's have that be a 27.0 and our date is going to be a text format. And so we'll have that be, um Let's see what is to the estate. So we've got the 28 of August right now, So that's we're going what we're gonna put in here. All right, so let's save us. One thing that we have to do after we insert data into our database is we're gonna go into our I'm Davis Connection and we're going to commit the changes this So let's save that. And that's run or code. Looks like everything went well. Let's go ahead and look into our database here. And so if we open it up and we go into here S o. R browsing the ice keeps melting table, we see that we've now got one rope data, which is at time zero, uh, temperature 27. And well, looks like our dick got a little bit messed up. Eso this is actually interpreted as a, um introduce obstruction. It seems like right now rather than hey string, which is strange, but it's OK. It's not really anything to worry about right now, because we're not putting in. We're not gonna put in these values like this anyway. Manually. Rather, what we're gonna do is we want to insert values dynamically, suddenly want to produce them my code and insert them like that. Um, so we'll see how to do that now. All right, so first, let's comment this out and we're gonna do is we're going to write a little for Luke. Some will say for I and range from 1 to 5. And we want to make sure since our time is already zero, and we've made it our primary key up here, we don't want to repeat I or we don't want to repeat our time. So we want to start one in this case just to kind of be consistent that we don't have the times euro again, which is our primary key. So these values should all be unique because we've made it our primary key appear. All right, so we're gonna have a little loop here and now to insert dynamically the way that we do it is we again use this insert into statement and put a table name. And again we'll have he's this value word here. The difference is after a table name. We're gonna specify let columns that we want so we can put in here many of the columns that we want to insert into, um, like this. And then we've got the values. And then, well, I'll put this on the next line, but should be on the same line we're gonna put in here the appropriate values like this. All right, So one thing that you should note is because we're actually defining which columns we want to use here. You don't have to use all of the columns if you don't want to. Um, so a good example of this would be that we can put in here the time and the temperature, But if we don't want to put the column in that state in there, we would just wouldn't specify that. Call him. It wouldn't insert it. So the value would be like, um, but you also see this in action will go into our cursor, and we'll go into the execute method. And what type of year in certain into our table name is cold Ice Cube melting like this. The columns that we're gonna want to insert into is gonna be the time. See me? Um, Temperature. And let's also do the date for now. Um, Weaken, leave it out again in a second, and then we're gonna put a plus here, and we're just gonna continue this on the next line so that it's easier to read. Then we'll put in a space and use the next keyword here, which is values, and now we'll specify the values. Now, since we're inserting this dynamically, there's one more thing don't need to do. And it's gonna be rather than putting in the values directly. And here somehow we're actually gonna put a question mark for each value that we're inserting. And then when we go outside of our string here, then we can actually put in the values. So let's say right now we're inserting three values time temperature date. So we're gonna put a question mark for each found you and this pretty much means this is where the values that will put in in a second, um, this is where they're gonna be inserted, so we'll go out of our stream will put in here comma. And now we're gonna pass a to pull. So we're gonna open a close parentheses, and we're gonna put in here as many values as we've specified here. So first, let's put in the time. And let's just have that B number corresponding to I the temperature that's ever temperature B 27 which is our starting temperature minus 0.1 times I. So every second we're just gonna be going down by 0.1 and our dates We can just have that be the same date as we have right here. And so we can put that in text format just like that. All right, so we've got that. The thing that we have to do again, just like appears we have to commit like this and settle. Let me close this and let's save and run. And so nothing crash and that's greatness. Let's go back into her database. That's open it up and let's see what we've got. So a prostitute him. And so we see here. We've got our time values in here. Our temperatures were going down by one, and now our date, of course, is working because we've passed it in here as a string rather than in here. You know where things get a little bit fishy. Um, so, yeah, you want to make sure that, um, we were gonna passing that We want to use this kind of dynamic input, first of all, because we don't actually want to just continuously, you know, specify the values that we want to put in. We want to do dynamically, but also because the four minute is a little bit easier. So one thing that we can try to get rid of this formatting error here as we can use the way that quotation marks with a pipe working pipin. So we'll go into at the beginning. We can if we want to rob our table sq melting so that we're resetting our data. Um, and now we can actually uncommon this. So the reason that I'm dropping the table rather than just running the command again, um, is because we've created our primary key as the time, and I don't want to have replicate values in there, So I want all these values to be unique because they have to be. So I'm going to drop the table first, and then I'm going to recreate it. And this time, rather than putting in the values like this. I'm actually gonna put a string around here like that. And so how close are database again and save. And from that, and then we can open it up one more time and we'll go ahead and brother data. And so now we see that the date is actually fine. Um, and so you can see you can get around these little nuances but using the different types of , you know, Python String indications. But of course, the better way to do it would just be to go about things like this where you inserted dynamically, of course. Also, this makes data inserting a lot easier because you could just insert the data as you get it . It's important to remember the syntax that we've got that kind of the three question marks year, each indicating a value for the three columns that we specified here. These are the appropriate columns. Let's do one more thing. What's making another fool must save Nala se for I in range. Um, from five up to, let's say eight. Um And so if we go into a database will notice our time, actually ends it for because our range goes up to, but not including this and value. So started five now, and I'm gonna copy paste this insert statement right here. The only difference is now, I'm not gonna insert a date someone to take all of these values out and this out, too, just to show you, you know how it works. If he don't have all the data or you don't want to insert all of the data for some reason, if you don't have all of the data at one point in time, then you know you just specify the columns that you do have or that you do want to insert data to a swell as their appropriate values. And, of course, we need to commit afterwards again like this. Um, but now we see we've also only got two values and are terrible here rather than the three that we've had appear because we're only inserting two values and I'm dropping my table still the front here. So I'm pretty much just redoing everything, which isn't the best way to go about it. But it's a nice wayto kind of work with this example. So it's called their database and let's run this and Let's go ahead and open things back up again. And if we browser data So now we see we've got these no values in here for dates because we didn't specify anything. Um, we even take things a little bit further. We can make another four loops. I'm just gonna copy Paste this over here. Now, I'm going to go from eight to 10 and I'm gonna show you that you don't actually need to specify that column order here. In the order that we have here. If I want, I can also flip these values around. What's important to note, though, is that the values that I'm inserting are gonna be in the value are gonna be in this order . So the first value here corresponds to the temperature. And so that's gonna be this fascist first value here. The second value corresponds to the second column that I've put in here, which is the time which is gonna be this value here. So let's closer database again. Let's save and run this, and there we go. So if it open it up again and we proud our data now we see you know our time is still consistent we still got the temperature here, even though we flipped the values just because of the way that we're inserting things. And, of course, we still have our no values down here because also down here, we're not inserted a date. All right, So this is how we can go about inserting data into our database using a static, which is what we've seen appear as well as the dynamic way. 7. Getting Data: Hey, everyone, it's Max and welcome back. So now that we've learned how we can insert data into our database, let's go ahead and look at how we can select data or get data out from our database so that we can actually use it, All right? And so the way that we would go about it is we, of course, connect to our database and create a curse on everything. I'm just gonna leave this execute statement appear, actually, all commented out. Just gonna leave it up here so that we have this format that we can always refer to and that we've got our column values in here and everything. Our column names so that we can refer to all of this so that we don't remember all of it. All right. Yeah. But anyway, let's go ahead and look at how we can get data from our database. And so the command that we're going to be using for that is called select M. And so we're gonna select, and then we'll put in here the columns that we want. So let's say call him one up to, you know, calm and which is however, many columns would want, and then we'll have a from keyword here. And then we've got our table name. So again, you don't have to put in all of your columns. Here, you can put it on Lee the columns that you want to select. So let's see an example of this. If we go on and execute the command, select and let's just select the temperature here. So, actually, copy paste is over to make sure we don't give any spelling stakes from our ice cube melting table. So we've got select temperature from ice. Keep melting with this. So what happened is now we've got all this data, but we still need to save it someone or access that somewhere using maybe a very well or something like that, stored or if we just want, you know, use it. One Tommy can also just printed out bullets. Save it in our variable. So our datum is. And now we're gonna use something that we talked about in the very beginning, which is this si dot Fetch any of these methods so we can start off. Maybe we'll just do si dot fetch all and that will give us our data. on, um, that we fetched and will save it in the state of variable here. And then, if you want, we can print out our data. And so if we save and run this, then we see that we got back as we've got back on our data, as it lists of in this case, just sing to polls. And so that's what we have as our temperature values here. All right, so really, we've went into our ice keeps melting database How? Rescue melting table. Um, in our training database. And we've selected the temperature column. If you want to select, say, temperature and time, we can well, weaken Do want weakening temperature in time like this. Then we can save and run. And so now we see you've got temperature First time. Second can also reverse this by putting the time here that save and run Sonali. See, we've got the time First the temperature Second, we're getting our data and to boom. And of course, we're getting returned as a list talked about in the very beginning. Instead of fetching all, we can also just fetch one piece of data first. If you like, you can say it and run. You can also get the date here to if he wants to get all three pieces of data saving run and said Now we see we've also got our date here and everything. Um, yeah. So that's the general way that we can go about it. There's different forms of syntax that we can use to. So you have this select and then we can she use columns? The second thing that we can do it, IHS. And actually, maybe I'll just put this down here and copy Paste this and change in a second. Um, and we'll comment this out so that we won't execute this anymore, but still have it to reference to. So instead of choosing which columns we want Teoh Teik. And if we want to use all columns, we actually have to write them all out. If we want to use all columns, we can actually put a year and Asterix And then we can right from. And then we've got our table name So rather than, you know, typing out all of these columns if we want to use all of them. What the axe tricks does is it means select everything from our table. So the Asterix really means to liked all of the columns. We're not leaving anything out. And so you can also just put that in here in this, for us, is the same as this, because this is all over columns. And this means select all the columns from ice keeps melting. And so if we save and from this we also see, we get the same response as appears, have fetched all the columns or we've selected all the columns which fetched the first row of data, which is what we have right here. Okay, cool. Awesome. So this is how we go about selecting the data. Now we can change our query a little bit too well, vary the data that we get there kind of pre, you know, have have some conditions to select only distinct or certain pieces of data. Um, and so let's do that now. And we'll maybe this year. Now and we just put this down here and what comment this out. Now we can act, um, special parameters. So maybe if we continue on with select everything from our table name, um, we can add in a limit if we want here afterwards, will specify the number of rows. And so what this does this is this is gonna limit the amount of data that we get and it's gonna limited to the number of rows I've been putting here. So let's say we've gotten millions of lines of data, but we only want to use like 10 of them, then weaken limit it to 10 rows of data. But if we this would usually give us the 1st 10 rows of data eso if we don't want the 1st 10 rows of data, say, and we can add and offset and here again will put the, um well, pretty much the row number or the number offset. And so that's what we're gonna put in here. So let's see an example about a say, we want to select everything from our ice cubes melting table. But we're going to limit this to two rows of Tatum and gonna have an offset of one. So we're not going to use the first row. We're actually going to start on the second row, so we're having we're offsetting our data by one. And so to see, you know what we got? Let's not do a fetch one. Let's do a fetch all to see all of the data that we got and we'll save and run a tsunami. See, we've only got two pieces of data, two rows of data. That's because we have limit. Did the number of data that we can get to to, and we also see that we don't start at the first row. We actually started the second row of data on. That's because we've offset the road that we get our data from by one. All right, so these are some of the parameters. Let's look a little bit more, has some other ones. So again, Well, take this statement here and we'll just put it down here so that we can kind of continue using it. So you got our limit and offset. Maybe we want to do a little bit of ordering instead. And so what we can do using this kind of general same syntax. First we could select. And of course, we don't have to put the star here. We can also put this column one through column and either one is fine. We'll just leave the star here just because we don't have to change anything around them. But of course you can specify a specific columns that you want, all right. But we can also say we want toe order our data that we get, and we want to order it by a specific column. So let's say first we want to order thing by the first column, and if we don't want to have a second column to order after that, then we can put that in here and so on, and then it can actually order by all the columns that you want. And so what this would do is first, it's gonna order by the first column. And so it's gonna look at the date of the first problem, is going to order everything, and it's usually going to do a sending, Um, and if there are duplicate values in there that it's hard to order them because they are identical. And so that's why you can have your second column here, for example, where you can then order that those kind of duplicate values and then you can go in on and on on and continue ordering on your data based on that So what's implement that? And let's say we want to select everything from ARTscape melting and we want to order it by , um and let's order it by the temperature column. And, well, actually not even gonna change your output. But that's also changed the way that we printed output A little bit for I will say for peace and data will print out are the piece of data that we can see things on the line by line bases, No, and so saving and run. And so we see here we're bordering by So we're ordering my temperature here and since it's doing a sending, actually start at the last row and go up to the first row rather than what we've had before , Um, we can also specify here if you want to do a sending or descending. So if you want to do a sending will put in here the A s c keyword, um, otherwise, we can also put in here, and maybe I put this on a new on line. If you want to do descending, we can put in here the descending keyword, But we'll put this in kind of square parentheses to do You know what that is? Optional. So, you see, I don't actually have to put this in here, but if I want to say, instead of, you know, a sending being the default, if I want to say descending, I put in here order about temperature, but we want to go descending. So we want to start at the highest value. And so if I save and run, then we seem now I'm ordering my data descending and course can also do the default a sending, but, you know, explicitly say it to make sure that's really what I get to get in a sending value sorted by temperature. All right, cool. So this looks really great. There's one more thing that I want to cover. So copy this and put this on a new line of Put that down here and common this out. Let's say you have a bunch of replicate data and you don't want to select all of it. So what you can do is you can type in here, select and let's say you only want distinct values or, you know you don't want the replicates. You say select, distinct. Like this. Um and then you can put in your columns. They're, you know, column names here or putting your column names if you want. Or we competed the Asterix. If he put in the Asterix, it's only gonna select distinct rose. And so all the data has to be unique. Whereas if we put in a specific column or calling names, if subsets of those rose specific to those columns are duplicates, then it's already gonna be, you know, distinct. And then so we can say so, like distinct columns from our table like this. And so it's implement that and, um, select like this and take all about away. So let's start off. Unless saying would select the distinct date from ice cubes melting on DSO, we're only going to select distinct We're going on Lee selecting from the date column here , and we only want to select distinct values in the date and self we save and run, we see is we get the date today, the 25th of August, Um, and we also get a nun date. But if we say select distinct date and temperature, if we save and run, then we're going to get pretty much all over values. They're actually all of our values because there is no replicate it of date and temperature . So we've got our dates here, but for each day, we've actually got a unique temperature. And so even when we're saying select distinct, we're getting Oliver data. Of course, if we had replicate temperatures for the same dates or for none date, then those columns or than those roads rather will be dropped down. And, of course, if you want, we can also add time in here. And as you probably noticed, as I'm doing this, the order doesn't really matter again. That's just going to specify the order that you get your date of return done. But then again, of course, I can save and run and we can see I get all of the appropriate data right here. 8. Conditional Searching of Data: everyone, It's Max and welcome back. So now that we've learned how weaken generally select data and maybe put, you know, some specific conditions on here Now, we're actually gonna look at how we can really specify conditions so we can have nice, conditional data searches to get exactly the data that we won't. So it will leave these values up here where these lines of code up here in comments just so that we can refer to them in case we forget something. Um, and Rocks. They're gonna be using a very similar syntax to do this conditional type of searching. So again, of course, first was select and can either do this column or the Starwood's do start because shorter, too, right. And we want to select from power table again using the table name. But now we can add a keyword called Where and inside here. Well, actually, we want to put a condition here, so that's where we could specify the condition Until this keyboard wear is going to allow us to say we only want to select the data wear. The following conditions are true. All right. So let's see some examples of this. Let's go ahead. And of course you want to execute and remember after execute, I still use this. Fetch all or you can use the fetch, wander, fetch many, and I just store the data that I get inside of this data variable. But to execute its SQL command will go into your cursor and execute. And let's just see, like everything from our ice cubes melting table. We're going to say where the following conditions are true. And let's just continue this on the next line so that we don't run out of space. And, well, what conditions can't we take? Well, we can do simple things like greater than you do less than we like we can do equals. And so notice that equals here is not the double equals that we know from Python. But it's actually just the single equals. Can also do things like not, but we'll see examples of all of us. Um, so it's first elect where and let's say where are date it is equal to, and then we're gonna put in here. Actually, another string using the single quotation works the 28th of August 2017 like this, and then we want to fetch all and just print. So let's just run those. Let's see what we get. Let's go through it again. All right? So get with this wear statement is we select all the columns from our Ice Cube lt table, but we only want to select the Rose where the date column has the value the 28th of August 2000 and 17 like this, Um and so we see that we get all of these values here and everything else that's no, we don't get If we want all of no values, we can actually do something very similar. So we can copy this and comment this out, and we can put this here, and we can use the is keyword No, like this. And so this is a different kind of, you know, conditions. So rather than using this comparison operations I'm like we've done before the year we've made sure date is equal to this string value here. Now we're saying date is the value? No. So we're saying is no rather than equals Noah's we have here. And so we get the other Rose where our data is. No, on where our date doesn't have any specific string value. And so what we can do very similar is we can actually use this, not keyword. And we can say you want to select, um, the values in our and Oliver columns where the date is not know, so it would pretty much be identical to this. But if we gather data on different dates, we want to get all of the data where our date did not know. And so if we save and run, then we see we get all of the values or all of the rows in which date is not know. All right, so this is the basics. Let's make this a little bit more complicated. Something that we can do is we can also add, and we cannot, or in here. And so let's see how that works. Well again. Copy this in. Just comment this out and put this down here. We want to select everything from Rs keep melting table where? Know what? Change this up a little bit. Let's say where our time is greater than five like this and want to say our temperature is , let's say our temperature is greater than 26.2. So we want to get all of the, um, rows of data, that course or that fulfill the condition where the time is greater than five and the temperature is greater than 26.2. So if we save and run, we see we get two rows of data. So you've got the time is greater than fire, which is six and seven, and our temperature is greater than 26 point. Choose that we've got Based on this selection, we've got this extra selection criteria that we have here. Of course, if we want, we can do this, or instead of the and on DSO, we can save and running. And so then we pretty much actually almost get all of our data because either the time is greater than five or the temperature is greater than 26.2. Um, we can maybe if we want, just flip one of these values to, you know, get a little bit more specifically in here and save that. And so now we're just kind of taking out the last two values because either a times this at five or temperature is greater than 26.2. Of course, this condition is completely fulfilled, always from this condition. But we still see that we don't get the 26.2 or the 26.1 value down here. So this allows us to do that more conditional, searching through a data so that we don't have to filter it later. Um, because accessing the database, you know, also takes time and everything, and so we can actually have this conditional filtering built in to our queries. 9. Updating and Deleting Data: a Rome, It's Max and welcome back. So now that we know how we can add data into database is a zealous into data tables, something else that's really important is not just adding new data, but maybe we want to update old data. Maybe we have, like, a customer database or something, and customers want to update their values. They want to update their settings, you know, their account information or whatever. It else. Um, we don't want add the person again because they're already there. We just want to update what we have for them. And of course, we also want to be able to delete people. For example, if people want to, you know, go out of some kind of questionnaire or you know no longer want to be taken part in the service, we also need to be able to delete them out of our database. Or maybe you wanna delete out bad data or all sorts of stuff like that. So let's first look at how we can update values, though, and then we'll look at how it can deplete values. So the general syntax for update is we're gonna have this update keyword and then we're gonna have our table name here and then we've got a set. Keyword. So really, we're doing is we're updating our table, and then we're going to have the sucky word here, and then we get a fine the new values that we want specific, um, that we want to have in specific columns, and so we'll see an example of this in a second. But the general syntax is that we could put him here as many or all of our columns, if you like, and for each of them, define value like this. And if we want, we can also add in conditional so we can say where you know. And then we've got a condition here, so we don't have to add the second part in, but we can if you want to. And it's usually good, because otherwise we just be updating your whole table and setting all of the rows in the columns that we're updating to the same value. So it probably be a good idea to, you know, have this way air conditioning here. And so before we run this, maybe let's just go into her table again. No, Here we go and just just take a look at that. All right? So maybe what we can do is we can update our table, and we can say where are date is? No. We want to update that to the state here so that we've got everything contest systems. So we're going to go into a cursor, and we're going to call the execute method so that we can execute our SQL Command and we're going to update the Ice Cube melting table M. And we're going to set the date column date, calm to the value. And then we need to put the extra stringing here. Also just doing interested, er subtraction the 28th of August 2017 and then we'll put a plus here to go on a new line, and we'll have the condition where the date is. No. So this is the condition if or rather where the date value is No. We're going to replace those values and set them to the new value, which is the 28th like this. Actually, let's just put it to the 29th just so that we can actually see the difference, and maybe we want him mess around with the state on a little bit later, too. Um, but you will set the date to be the 29th of August, but only in the cases where the date is no. So let's close our table here. Let's save. And just to make sure we want to go into a connection and commit, um, and save and run and we'll go over here and let's look at a database now browser data and so we can see that where we happened. No, before the values have been replaced by the 29th. We can also see that everything that wasn't no is still the 28th just like we've had it before. And so this is how we can use this updates method here. All right, so what else can we do with the update? Well, we can, you know, rather than just choosing one. Maybe we want to populace and, you know, comment this out and we'll put it over here. And let's do this for multiple values. So we'll set the date and let's set it to be the 30th now, Um, and we'll add another condition here. So or rather, another setting a value will set the date to this and will set the, um temperature to be 26.5 where and now, rather than saying where the data is? No, because our date isn't alone. You know, let's say where the time is greater than Well, let's go with six. So when the time is greater than six so these last three rows, we want to set our temperature 26.5 and we want to set the date to the 30th. So we see we're setting to values here. We still need to separate this by comma. So they got a call in one, which is that we have here got are equal for setting the values. We've got a value one for our date column, which is gonna be the 30th of August. Then we have a condom column, and then we can start with the next column, which is gonna be the temperature. Colin will set that to be the 26.5, and then we've got a conditional statement, which we can, you know, she indicate using this way or key word here. So we close save and run. We're still committing. I forgot to close the string over here and some will save and run. And if we open our database backup and we problems the data So now we see where the times greater than six. So I've got 789 Our temperature is now 26.5 in each of these cases and the date is the 30th just like this, right? So that's how we can go about updating everything. Now, let's take a look at deleting. So to delete, we're going to use the delete key word, and we're gonna say we want to delete from And then we've got our table name here and also here. If you want, we can add a wear condition. So let's see example of this we'll execute following SQL statement will say you want to delete friend, and I'll just copy paste the table name right here from the ice cubes melting table. And we wanted elite where our time is less than five. So all the values where time is less than five. So all of the use you want to delete and then you can see we're still committing. We save and run and here again, we open up our database and lets you get some eyebrows. And we see everything where the time is, less than five has now been deleted. All right, if we don't just want to delete based on condition, but we want to delete everything, we can do that too. We can just say delete from and then we've got our table name here. So see this in action I want to delete from this Ice Cube melting table. And what this is going to do is it's gonna delete all of the data inside. So rather than when we dropped a table, which also completely deletes the table from here. If we just, um, delete from the table, we're just going to delete the data contained inside. And so it saved close and run this and let's open up database again. Let's take a look. So if he promised the data, we see the inside of the ice cubes melting table. We now have no data anymore because we've deleted everything. But we see our ice keeps melting tables still exists, so we didn't drop the table or anything. We just deleted the data contained inside. All right, So this is how we can go about updating them values as well as the leading values, which can be pretty important parts of SQL queries to and also of managing your database. 10. Course Outro: everyone, it's Max. And I just wanted to say congratulations on finishing the course also want to remind you to make sure to go through the practice exercise and the project section, we're going to take some CSP data and basically go through the whole process of creating a database and just inserting that data and then also extracting that data based on, well, two conditions that I gave you. Now, I also gonna want to encourage you to start saving your data in an SQL database and basically get used to extracting your data using SQL and then continue on using that data in python rather than just saving it and kind of a local file and loading that file that where you're going to become a lot more comfortable working with SQL databases. Which is important because a lot of data is stored in SQL type databases. Thes days