Python MySQL Tutorial - Creating Tables, Inserting & Selecting

  Рет қаралды 215,926

Tech With Tim

Tech With Tim

Күн бұрын

This video discusses how to create tables, insert data and select information from a MySQL database with python. It will show how to insert data into a MySQL database, Select and show the information.
Playlist: • Python MySQL Tutorial ...
◾◾◾◾◾
💻 Enroll in The Fundamentals of Programming w/ Python
tech-with-tim.teachable.com/p...
📸 Instagram: / tech_with_tim
🌎 Website techwithtim.net
📱 Twitter: / techwithtimm
⭐ Discord: / discord
📝 LinkedIn: / tim-rusci. .
📂 GitHub: github.com/techwithtim
🔊 Podcast: anchor.fm/tech-with-tim
💵 One-Time Donations: www.paypal.com/donate/?token=...
💰 Patreon: / techwithtim
◾◾◾◾◾◾
⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡
Tags:
- Tech With Tim
- Python Tutorials
- MySQL Python Tutorial
- Python MySQL Tutorial
- Python MySQL Connector
- SQL Python
#Python #PythonMySQL #SQL

Пікірлер: 120
@arielmaritano6470
@arielmaritano6470 4 жыл бұрын
I've been watching your videos for a while now, and I've learnt a ton from them. I can't thank you enough! 🙏🏻
@thilokeshjain6767
@thilokeshjain6767 4 жыл бұрын
I thought it would be very complicated but thanks to you sir feel like I can master this. Thanks a lot 👍.
@allegra13
@allegra13 2 жыл бұрын
tim you have no idea how much you've saved me with your videos, THANK YOU SO SO SO MUCH
@oscargarciahinde4247
@oscargarciahinde4247 2 жыл бұрын
I'm getting into SQL after neglecting it for years (didn't really need it in my job as an academic researcher) and your tutorials got me up and running in no time. Cheers mate!
@Goutham-exists
@Goutham-exists 13 күн бұрын
nah id win
@jj342
@jj342 3 жыл бұрын
absolute great tutorial! so simple and easy to understand! Could you number your videos in the playlist? Might make it easier for people to follow along
@StraitBizness
@StraitBizness 3 жыл бұрын
Thanks for the videos on this. It helped me out quite a bit with linking up mySQL and Python for a project I am working on.
@cusematt23
@cusematt23 8 ай бұрын
TIM, I used to think you weren't the greatest at explaining things and spoke a bit too generally. But I think I was absolutely wrong and just needed a slightly better base in computer science to follow along. Your videos are mastery (this series and the one on GIT I think in particular). Keep up the great work!
@Atheawesome45
@Atheawesome45 4 жыл бұрын
Hey Tim! I’ve recently downloaded sublime text and was having issues installing the packages. I’ve checked your uploads and couldn’t find any video on your channel having to do with this subject. I’m certain that I’m not the only one who would be interested in seeing this kind of content. Nevertheless, keep up the great work and thank you for the educational content!
@TheShadyStudios
@TheShadyStudios 4 жыл бұрын
you’re choosing the best things to work on m8 thank you
@MrSith-yp3yq
@MrSith-yp3yq Жыл бұрын
Excellent as always, Tim!
@caolanmaguire9874
@caolanmaguire9874 Жыл бұрын
Great tutorial! Helped me with a project!
@sebastiengagneux2561
@sebastiengagneux2561 2 жыл бұрын
Hello TIm! Your videos are very helpful in my daily work. Thanks. There is one topic that I am sure you can answer and will be very usefull for the community (and me as well :) ). it is about reading data from SQL in GO. Ex: I cannot find any answer about using the join method in sql for reading 2 tables, but in GOLANG. always based on 1 table.
@datofficial6062
@datofficial6062 Жыл бұрын
Very basic. LOVE IT!
@hosseindr.askari6161
@hosseindr.askari6161 Жыл бұрын
Thanks for your great explanation 🙂
@EricRosenberg
@EricRosenberg 2 жыл бұрын
Fantastic tutorial, thanks! 👍
@wsanders669
@wsanders669 2 жыл бұрын
Excellent. Thank you
@arnavkhandelwal30
@arnavkhandelwal30 2 жыл бұрын
Thank you !! ur help has been helpful
@mouhannadal-hmedi1501
@mouhannadal-hmedi1501 4 жыл бұрын
Great python courses 😍😍😍 countinue
@muhammedfadhi789
@muhammedfadhi789 2 жыл бұрын
the way you explain... amazing...
@TechWithTim
@TechWithTim 2 жыл бұрын
Thanks a lot 😊
@hindustaniMemer565
@hindustaniMemer565 3 жыл бұрын
thanks buddy it helped a lot...
@jayamankrah4328
@jayamankrah4328 4 жыл бұрын
Thanks for this video
@thenaturelover5737
@thenaturelover5737 2 жыл бұрын
nice work bro...thank u sooo much...👌👌👌👌👍👍👍
@darnellhill143
@darnellhill143 3 жыл бұрын
Video super helpful!!! I am using the pymysql library, and I could not figure out why my inserts weren't reflecting on my MySQL DB.... I forgot to commit the changes. I made use of the autocommit expression. Thanks!!!
@saikoushik7626
@saikoushik7626 Жыл бұрын
Thank you so much bro
@Alan-yg8wc
@Alan-yg8wc 4 жыл бұрын
Hi Tim, what if I want to pass in a list with 2 elements with a name and age instead. How would that change the code? BTW I love your videos!
@shreyasreedhar2068
@shreyasreedhar2068 4 жыл бұрын
this is very helpful,.. just one thing: at 13:23, i get three such rows
@dasigkatama029
@dasigkatama029 4 жыл бұрын
Simple and helpful :-)
@kasyapdharanikota8570
@kasyapdharanikota8570 3 жыл бұрын
very helpful video
@geethanjaliravichandhran8109
@geethanjaliravichandhran8109 3 жыл бұрын
Thankyou tim
@post_nut_clarity
@post_nut_clarity 3 жыл бұрын
you are a genius.
@victorlefeu
@victorlefeu 3 жыл бұрын
thanks you!!!
@dinonppa1
@dinonppa1 4 жыл бұрын
Can you do a series like this but for sql server? Keep up the good work. Love all of your videos!
@soulninjadev
@soulninjadev 3 жыл бұрын
its very similar just google one or two things for the setup, rest everything is the same
@jagadishs1086
@jagadishs1086 4 жыл бұрын
Sir awesome
@rediscover.themystery
@rediscover.themystery 2 жыл бұрын
I really love you brother. I feel comfortable when I heard you. Best explanation...
@TechWithTim
@TechWithTim 2 жыл бұрын
Really appreciate that! Thanks :)
@johnygrits
@johnygrits 3 жыл бұрын
hello, I've been following your channel for sometime now. thanks for the uploads and great explanations. Where did you learn how to code? I am starting out on my own and would like some recommendations if you dont mind! Thanks again!
@Blu3_Spac3
@Blu3_Spac3 Жыл бұрын
Only 1m subs??? you deserve more
@Ricqua
@Ricqua 4 жыл бұрын
Great tutorial!!! Please let me know how to change my text to change color dynamically. Can't seem to figure it out x_x
@sainco3036
@sainco3036 4 жыл бұрын
thanks.
@MOHAMMADFARIHANABDULLAH
@MOHAMMADFARIHANABDULLAH 3 жыл бұрын
Thank you..Hope you can do it video for Telegram Bot with mySql run on pc.
@youtubepanda8238
@youtubepanda8238 Жыл бұрын
You saved my hassssssssssssssss 🤕🤕❤❤❤❤
@pjb4764
@pjb4764 6 ай бұрын
Great video! Could you please explain the “VALUES (%s, %s)”, (“Joe”, 22)? If I try formatting a string in this way the string is not formatted. Is there any resource online that explains this method?
@Tirik00
@Tirik00 9 ай бұрын
Great Video ! The code works but how is it possible to highlight the code and activate autofill like in the video ?
@pedrotorres5539
@pedrotorres5539 4 жыл бұрын
Hi Tim, I have been trying to replicate your tutorial, however whwnever i run mycursor.execute("DESCRIBE Person") or mycursor.execute("SELECT * FROM Person") it doesn´t seem to store anything in my cursor in fact if i try to fetch it it sends an error saying there is nothing to fetch... Any ideas what might be happening (I already checked and the data base with the table and the info are created).
@kailashrathod1089
@kailashrathod1089 4 жыл бұрын
Make different video where you can just explain sql querries(in oracle or something like that) and then continue this series so that it will be easier for the people with no database knowlege that how querries actually works! Great video though!!!
@SS-xt5ul
@SS-xt5ul 3 жыл бұрын
try from mosh sql tutorial . perfect
@kclonh4517
@kclonh4517 4 жыл бұрын
Hey what code font do you use? I really want to try it out.
@uncommoncharlie7
@uncommoncharlie7 3 жыл бұрын
Hi Tim , This video is really good. I'm stuck in one spot. When I tried to create the table I got an error that I have a reference error: weakly referenced object no longer exists. Do you know how to fix this? I've looked everywhere but nothing seems to be working.
@Sam-tg4ii
@Sam-tg4ii 5 ай бұрын
If I am doing multiprocessing and workers are writing rows to the same table concurrently, d I need to initiate cursor for each worker?
@outdated7742
@outdated7742 4 жыл бұрын
what would be nice is you can make a video and connect your voice assistant with a database and when someone first run it it should ask for name,age ... and then use that info for e.x say hello + name
@ayushpurohit8266
@ayushpurohit8266 Жыл бұрын
is there a difference between using %s, .format() and f-strings?
@krokkozerro7582
@krokkozerro7582 4 жыл бұрын
make video about opencv pls
@TheAmazingpower
@TheAmazingpower 4 жыл бұрын
Nice video, only thing I would not recommend is using string commands on the execute function. SQL offers own ways for that. Otherwise your software/application will get vulnerable for a sql injection attack because users can insert malicious commands.
@TechWithTim
@TechWithTim 4 жыл бұрын
What string commands would you not recommend? I believe I did it properly with the formatting and the variables inserted in a tuple passed as a second argument to the execute method.
@TheAmazingpower
@TheAmazingpower 4 жыл бұрын
​@@TechWithTim Edit: Seems like I've been working with sqlite too long. I did some research and noted that the paramstyle for mysql is 'pyformat' which is %s in this case, whilst it is a '?' for sqlite for, %s should be legit here and sanitize the input. Sorry for the confusion. It also also good to mention that in this case the %s is not similar to the regular %s for string formation in a non sql string you would usually use for printing or for the generating a standard output string. The best method is to use parameterized querries, for example in Python sqlite you use the '?' sign: db.execute("INSERT INTO staff (person_id, lastname) VALUES (?, ?)", (51, "Mc'Donald")) You could use any predefined variables instead the number and string in the bracket as well. I think therefore the module got some build in protection other than using the regular string format option like %s, string templates or f-strings. In the worst case (with some user input in the programm) input like 'password' OR 1=1' could potentially break your querry. If you are more interested in that, you can look up the topic "SQL Injection" as well.
@SatishKumar-mn6bi
@SatishKumar-mn6bi 7 ай бұрын
nice guidance by you. Hey I am also learning python for fun!
@JustaNormalGuy115
@JustaNormalGuy115 4 жыл бұрын
Pls do a video on Json files and how to use them with python!!!
@andrewn211
@andrewn211 4 жыл бұрын
www.programiz.com/python-programming/json this seems to be a good article on it but i think he has a video on JSON already i think so i may be wrong so s0rry
@JustaNormalGuy115
@JustaNormalGuy115 4 жыл бұрын
@@andrewn211 thx but I already figured it out myself. It was 9 months ago...
@jean-paulzimmermann6366
@jean-paulzimmermann6366 9 ай бұрын
Which version of mysql-connector should one use?Because on september 23 it doesn't work. thanks
@captainyaptin5811
@captainyaptin5811 2 жыл бұрын
Is there any way you could make a quick video explaining how to do this with a Django project? Thank you!
@hassanprinceoftheyes9365
@hassanprinceoftheyes9365 2 жыл бұрын
For your information a pizza has 2,269 calories, idk what pizzas you eating, but like hand em over
@gandalfgrey91
@gandalfgrey91 2 жыл бұрын
how do you get that CLEAN syntax highlighting for mysql?
@sarthakkavidayal4968
@sarthakkavidayal4968 3 жыл бұрын
why are we using %s for integer value as well? %d is used for the integer value.
@johnylanckriet3377
@johnylanckriet3377 9 ай бұрын
How do wet get all those different colors in the the query string?
@wilbertraymundrayos4175
@wilbertraymundrayos4175 4 жыл бұрын
Hello, I have a question regarding inserting. Is it possible to do this? "INSERT INTO %s (%s) VALUES (%s)" I tried it, but it gives me error. MySQL does not tell the exact error, it just says check the mysql version regarding the syntax. My theory is that the tuple automatically assigns a quotations in the values that are being passed in the %s. Since the table name must not contain quotations, it returns an error. My question is... Is there a way to do what i want to do? Which is to dynamically assign table name and column name.
@neilzietsman4220
@neilzietsman4220 4 жыл бұрын
Thank you for your video Tim. What is the purpose of "%s" at 11:20?
@abhiencoded
@abhiencoded 4 жыл бұрын
Neil Zietsman %s is like a variable whose value is defined after the string
@Kig_Ama
@Kig_Ama 3 жыл бұрын
@@abhiencoded But what's the advantage of it in this case? At the end he still types his name Tim again. I didn't get the point.
@firstname8078
@firstname8078 2 жыл бұрын
@@Kig_Ama 11:10🙃
@ProSpase
@ProSpase Жыл бұрын
is it possible to do this in pycharm community edition?
@jamesgoforth5644
@jamesgoforth5644 20 күн бұрын
13:24 my print statement after cursor is not executing only output is a mysql command prompt, I put a print statement before mycursor is initialized, and that one prints
@deanemarks8611
@deanemarks8611 Жыл бұрын
How about dfs to dba and vice versa
@vietndk5437
@vietndk5437 4 жыл бұрын
the string query in method execute() does not need the semi-colon ";". For me, the semi-colon is like a sign for user to know where the statement ends.
@Kig_Ama
@Kig_Ama 3 жыл бұрын
But there is no semicolon.
@shanksharma5117
@shanksharma5117 2 жыл бұрын
can you provide tutorial for Sqlite3?
@samuelpurple
@samuelpurple 3 жыл бұрын
What software is this please?
@radio_electronics4047
@radio_electronics4047 3 жыл бұрын
How can I insert "curdate()"? It says Incorrect date value...
@rankzkate
@rankzkate 4 жыл бұрын
how do I show tables from a database that I can only read from?It is not my database but was given for practice? Please help am stuck.I tried "show tables" but it failed
@fernandohood5542
@fernandohood5542 3 жыл бұрын
Why do some people use ; after the commit?
@twinbook9025
@twinbook9025 4 жыл бұрын
Can someone help me in my topic that how i can generate invoice using my sql plz if someone know help me
@datasciencewithcharaf4206
@datasciencewithcharaf4206 Жыл бұрын
How can I make SQL scripts colored like yours please (I'm using PyCharme) !!
@abinayas6221
@abinayas6221 3 жыл бұрын
Or any compiler
@ayooshsharma529
@ayooshsharma529 Жыл бұрын
Where are you writing these commands????
@brucescott7156
@brucescott7156 2 жыл бұрын
For some reason the commit isn't working for me, I'm not getting errors, but my db is not being updated.
@masterludovicus802
@masterludovicus802 3 жыл бұрын
I'm trying to follow along and writing the exact code on Sublime and run it and I get an authentication plugin not supported The exact line I get is mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password" is not supported What am I missing?
@ParkesBench
@ParkesBench 8 ай бұрын
I had the same problem and passing auth_plugin='mysql_native_password' did not work, because I accidentally installed mysql-connector instead of mysql-connector-python (via pip3). Just leaving this here in case it helps someone.
@soumya9895
@soumya9895 4 жыл бұрын
Hey Tim I know sql is very useful/important for getting job but it's kinda boring for people who wants to make interesting projects to show their friends who do not know programming. Maybe you could do some python projects like you have done chat bot and voice assistant alternatively.
@TechWithTim
@TechWithTim 4 жыл бұрын
Agreed, that being said because if it’s importance I will continue to teach it!
@maarcoo97
@maarcoo97 4 жыл бұрын
maybe there's other people doing want you like
@soumya9895
@soumya9895 4 жыл бұрын
@@maarcoo97 well yeah i know but i love how Tim explains in an interesting manner
@geogaddi84
@geogaddi84 2 жыл бұрын
SELECT * FROM Person is only returning the first tuple for me. Not sure why. If I were to use MySQL directly, that'd work as intended
@INSANE_-nj4xh
@INSANE_-nj4xh 2 жыл бұрын
Bro I can't create 2 table in a single prog. Can u give a small example on how to do it.
@DGMDevGamingAndMore
@DGMDevGamingAndMore 3 жыл бұрын
I'm not getting any errors, but the data isn't going to the database (ClearDB)
@aradog3213
@aradog3213 3 жыл бұрын
2.35
@Rbourk252
@Rbourk252 3 жыл бұрын
String formatting in MySQL requires a minimum of (%s,%s) otherwise this throws an error. A single (%s) will not work.
@Kig_Ama
@Kig_Ama 3 жыл бұрын
11:08 I don't get it. Why not just type Tim, why use %s and type Tim afterwards anyway? What's the advantage?
@Dalt0nik_
@Dalt0nik_ 3 жыл бұрын
As i get this, without those "%s" you can only write some hard numbers itself (just as he does in both ways, he right info itself, not a variable), while using them you can write any variable instead of "Tim" and "19". So %s is essential if you want to put there a variable.
@Kig_Ama
@Kig_Ama 3 жыл бұрын
@@Dalt0nik_ Ty, I understand but at the end doesn't he hard code in this tutorial anyway?
@Dalt0nik_
@Dalt0nik_ 3 жыл бұрын
@@Kig_Ama Yeah, he does, but I guess he just wanted to show us the best way to write it, so we could be able not only hard code. (Like if he couldn't mention this I would definitely think I can write a variable there without any %s)
@Kig_Ama
@Kig_Ama 3 жыл бұрын
@@Dalt0nik_ Uhm ok I guess I understand. Great, ty for your help!
@cinquecento1985
@cinquecento1985 3 жыл бұрын
Screw this. I want a pizza now.
@johnhupperts
@johnhupperts 4 жыл бұрын
how many calories is a pizza? like 400 or something lol
@TechWithTim
@TechWithTim 4 жыл бұрын
oops xD
@BrianPotterProductions
@BrianPotterProductions 4 жыл бұрын
Ah, youth. 😂
@abinayas6221
@abinayas6221 3 жыл бұрын
Ur using mysql appa
@avik5052
@avik5052 4 жыл бұрын
Why is there one dislike?
@Alphabet_-_
@Alphabet_-_ 4 жыл бұрын
@q_c9411
@q_c9411 3 жыл бұрын
@DoraTheExplorerrr
@DoraTheExplorerrr Жыл бұрын
@@q_c9411
@akshatrawat3943
@akshatrawat3943 3 жыл бұрын
i dont understand how the fuck does the database connect to python for him . i use pycharm and have been facing trouble for weeks. please help me out if u can.!!!!
@stephenfulmer8646
@stephenfulmer8646 2 жыл бұрын
This video didn't make any sense. The lines of code written for some reason do not work. Why is this so difficult!?
@MrPelastus
@MrPelastus Жыл бұрын
Excellent video! I am having trouble with this code. I am getting an error 1064 message (MySQLInterfaceError: You have an error in your SQL syntax;). I cannot find where the error is. Any help will be appreciated. here is the code: create_employees = """CREATE TABLE Employees ( EmployeeID INT AUTO_INCREMENT PRIMARY KEY, Name VARCHAR, Role VARCHAR, Address VARCHAR, Contact_Number INT, Email VARCHAR, Annual_Salary VARCHAR );""" cursor.execute(create_employees) print("Employees table was successfully created. ")
@thebigmightybattleship
@thebigmightybattleship 11 ай бұрын
I had a problem but it was completely different. Is it because you didn't define the length of each VARCHAR?
@MrPelastus
@MrPelastus 11 ай бұрын
@@thebigmightybattleship Thanks for your comment. Yes that was one of the problems.
Python MySQL Tutorial - Selecting Data & Altering Tables
11:28
Tech With Tim
Рет қаралды 68 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1,1 МЛН
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 54 МЛН
LOVE LETTER - POPPY PLAYTIME CHAPTER 3 | GH'S ANIMATION
00:15
you need to learn SQL RIGHT NOW!! (SQL Tutorial for Beginners)
24:25
NetworkChuck
Рет қаралды 1,4 МЛН
MySQL - The Basics // Learn SQL in 23 Easy Steps
17:17
Fireship
Рет қаралды 808 М.
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 795 М.
SQLite Backend for Beginners - Create Quick Databases with Python and SQL
13:32
Python MySQL Tutorial - Foreign Keys & Relating Tables
16:57
Tech With Tim
Рет қаралды 80 М.
Python Object Oriented Programming (OOP) - For Beginners
53:06
Tech With Tim
Рет қаралды 3,3 МЛН
10 Python Comprehensions You SHOULD Be Using
21:35
Tech With Tim
Рет қаралды 128 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 80 М.
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 54 МЛН