 Just so you know, if you hear a low bassy sound, some neighbors like two blocks over have their car stereo going and I can just hear the low bass. Gotta love people who just love sharing their music. Anyway, today I'm going to talk about something that was asked in a comment of a recent video. I, you know, not too long ago did a series on SQLite, database stuff, very basic stuff. And someone said to me in their comments is that how they really like using plain text files. But they were working on a project and they were wondering if I thought that using SQLite database or some sort of database would be better than a plain text file. And my answer to that, it all depends. I really like doing stuff in plain text files. It's very simple, but it's going to bite you in the butt in certain cases. So my main rule of thumb, first thing I need to think about is am I going to be writing a script that is going to update that information. So if you're just entering stuff in and that stuff you entered doesn't change, but you're just logging stuff, in my opinion. And then I'm talking about personal use here, you know, if you're, if you're doing something that other people are going to be using, and there's going to be a lot of people, lots of times a database is going to be better. But if you're just logging stuff, so you're keeping track of something and you're adding new things to the list and you're not modifying the previous stuff, plain text is fine. But once you get to the point where you might want to change information that's already in there, for example, and I use this as an example a lot because it's a very common thing that you're going to create if you're going to do any type of business work is, you know, an employee database. You're going to have a database of their first name, their last name, their employee number, their phone number, their address, what department they work in, their title, their hire date, that sort of stuff. Well, you know, if someone wants to change their phone number because their phone number changed, writing code that modifies a plain text file, you can do it. It's just it can become a real headache. Because what are you going to, you're going to delete out the old line and replace the old line or are you going to try to set to replace that? No, that just gets really messy and we'll come back to bite you. So anytime, if you're going to be updating previous information in there, database is probably a way to go. But if you're just logging stuff and it's personal use, plain text is mostly fine. You know, you're going to log it, search it and maybe display it somehow. Now as an example, something that I've been doing for two or three years now, I created a simple little interface and sometimes it's easy to create a little form that submits stuff to a text file. But I have an application running on my web server that I have an icon on my phone. And it's actually on my phone. It's just a little picture of a car. And when I click on it, it lists my current two cars, my wife's car and my car and even has a log from my previous car because I was using it then. And it displays a list. So it displays all the cars I click on the car. I want and displays a list of all the stuff I've logged. And it's three columns and it's all in rows. The first column is the date, then it gives a description. And then if it's something that costs money, the price there. So if I got the oil change, there's the date, there's just says oil change. Maybe I put the mileage in there. And the next column is how much I paid. So, but the way I enter stuff into that is actually just SSH into my server and open up that file and Vim. And I have a separate text file for each of those cars. And I actually liked it so much that I recently added my house track of house expenses. And when you go in there, I just Vim, I type in the date. And then each column is separated by a pipe. So I type in the date, a pipe, description, pipe, price if there is one. And then I do a back tick and a URL if there is one. And what happens is if there is a URL in that list on my phone, if I click on it, it actually brings me to a URL that can be anything. But in most cases, it's documents. So for example, I got my let's say I changed my own oil, which I just recently started doing because a friend is showing me how to do that. I have a list I have here, you know, this is the date and it says oil and filter change. And then it says the price. But then when you click on that row, it actually brings me to photos I took of the bottle of oil, picture of the box for the filter and the receipts. So I have a record of what filter I used, what type of oil I used, and how much I paid. And that way in the future, when I go to change my own oil myself, I go, oh, that's the type of oil I got. I know that's the right one. I know that's the right filter, you know? And so it makes it real simple. But I'm doing that myself. So I'm just searching, actually I don't just VIM, since I have multiple files, you know, one for each car and one for my house and stuff like that. I actually set it up that when I SSH into my server, my last three cars are Mazda. I just type Mazda and hit enter and actually uses FZF, which is a fuzzy finder. And it lists all those files for the three different cars in my house. And I can select it and it brings me into that and VIM. So all I have to do is type in Mazda, hit enter. And then if I want my newest car, I type in 2016, hit enter. And I'm in that file. I add a new line. And if I want to, I can go back and change previously entered stuff, which I usually don't. But it's very simple for me to go in VIM. But if you're creating something for other people, you in no way want them to have access to how things perform. Because they will screw up the formatting just horribly, even if you try to make it as simple as possible. Anytime you're writing code, the hardest thing is thinking, what is the end user going to do? So for example, this is, I'm going back 10 years, a little more than 10 years. I'm looking at, yeah, probably 0809. So about 10 years ago, I was trying to help out at work. I had previously done some peer work for them. I didn't really want to be involved, but I want to kind of steer them in the right direction. So I create a little interface for them that displays stuff that's logged. And to make it as simple as possible, I didn't want to create an interface that updates the stuff. So what I did was I create a Google spreadsheet. I gave access to this lady who was in charge of it. And I set it all up, format it out. And I said, all you have to do is enter in the stuff here. In fact, I even created a form so it enters stuff into that database. But then my interface displays the stuff. Well, in each column was a different thing. All she had to do was enter in the information. Well, she decided she wanted to change the way the spreadsheet looked. And she started moving the columns around. I was like, no, you can't, you obviously can't do that. At least to me, it's obvious. But she's like, oh, yeah, I moved those around. Now things aren't displaying properly. So it's like you never, and I normally wouldn't do that. But again, I was trying to not be involved because it was a headache. And I was just trying to help, but not really help. But yeah, you never want to give someone access to how that information formats. So plain text, yeah, you're going to want to write your own interface for them to enter the information, whether it's going into a database or a plain text file. And also, if you're creating forms where they enter stuff, you want to limit what they can type. So let's say they have to enter their name. You don't want to give them a text field, an input field where they can type their name. You want to give them a dropdown that lists all the employee's name and they select their name from that. Because now, like I'm Chris, my name's Christopher. I go by both. Sometimes I write Chris. Sometimes I write Christopher. You know, let's say half time I write as Chris, half time I write as Christopher. You know, or I actually tend to misspell my name a lot. My last name has a lot of I's in it. And when I type fast, I always miss the second to last I. Almost all the time. I catch it almost all the time. But you know, what if I type my name wrong? Now we're trying to search through database and it hasn't come up. So let them select, you know, from a list. If they enter a date, give them a calendar pop up to select the date from. Don't let them type the dating because people will type the date all different types away. So you want to limit what people can do as much as possible when it comes to input. You want them to be able to enter the information they need to enter, but you don't want to have them type it in. Anytime you can have a, you know, a bar where they can choose a number or, you know, a drop down menu rather than typing something in or a date, select anything like that where they pick things from a list rather than typing stuff in the better. Now maybe that you can, they can type stuff to filter the list or search the list. But you, if you can limit them to what's in the list, always do. But going back again, rule of thumb when it comes to plain text versus database, database is usually better, but not always worth the headache of setting up. Although if you do it a lot, like, like I do, you create scripts, which I do have up on GitLab to kind of automate a lot of the process. But if you're just dumping information into a log and logging the stuff, plain text is fine on small projects. Obviously once you get to, you know, Facebook size stuff, that would, that would be really stupid to do stuff as plain text there. You're going to want to do it as a database. It's going to be more efficient and, and you're going to want to do better database stuff than I do because I am definitely not a professional. It comes to databases. I use the bare minimum skills just to put stuff in and update it. But even if you're doing something for yourself, unless you're going to go open up Vim or somewhere text there and add the text, if you're going to create an interface that not just enter stuff into the database, but allows you to go in and update stuff that's already entered, you're going to want to use a database rather than a plain text file because before I started doing database stuff, again, going back like 10 years, that was probably about when I started doing a little bit of dabbling with my SQL. I used to do everything plain text and, and one, it can be very slow if the files get large. But yeah, it's like you want to update. Here's that, that employees row. It's like, how do you update that? And like the simplest way would be to grab that line, delete it out of there, make the modifications to it, and then dump it back into the file and now it's at the bottom of the file. You can try to replace it in line, but it's just, it's, it's messy. But I still use plain text for a lot of stuff. For example, I've done a few videos on my water pumps. So I got two pumps and I got to ESP826 chips that just send signals to my web server, HTTP requests, when the pump's on or if it's been running for a while. That's just all dumped to a plain text file. Again, my car thing, if it's just dumping stuff in there, but in any case, always make sure that you have it formatted in a way. Because another thing is if you haven't formatted well, you can always convert or import it into a database if you decide to make the change later on. Of course, you can go the other way as well. You can dump your, your database into a plain text file, but usually if you've gone that far to create the database, you're not going to go back to a plain text file. But if you have some sort of CSV file or TSV file where you have the limiters, usually commas or tabs, I usually use the pipe symbol. Just because it's simpler people when typing stuff don't normally use the pipe symbol, but like a comma they would use in an address or something, in which case you have to write your code to take that into account. And even if you are using a symbol like a pipe symbol, you're going to want your interface to search that before it puts it into the plain text file. And again, most of the time I'm doing it myself, so I know not to do that, but if other people are, you want to replace that pipe symbol with something else, you know, anything you're going to use as a delimiter, you want to make sure that that's fixed. And there's code out there to help you with that. But that's my thoughts on plain text versus database. Depends on your situation. If you're just doing something personal for yourself and it's very simple, and you're logging stuff that you might display or search through later, most cases plain text is fine. But you're going to really bite yourself in the butt if you bite yourself in the butt. I don't even know if that's not really a saying. You're going to get bit in the butt. It's going to nip you in the butt. That's what I'm looking for. It's going to nip you in the butt if you're trying to create an interface that other people are going to use that's going to be updating information in the log if you're just using plain text file. It's going to be more of a headache than taking the 10 minutes to learn a few commands for working with some sort of SQL database. Because you just need to know how to enter stuff and update stuff once you get going really and maybe delete something. Anyway, thanks for watching. Filmsbychrist.com. That's Chris Decay. A link in the description of the video. As always, I thank you for watching and I hope that you have a great day.