Using MySQL Databases With Python Course
Vložit
- čas přidán 23. 07. 2024
- How to Use MySQL Databases With Python! These days everything uses a database, and MySQL is one of the most popular databases out there. FREE and Open Source, Mysql is a great database for just about all your needs.
Likewise, Python is one of the most popular and powerful programming languages today. Pairing the two together is a powerful combination!
In this course you'll learn the basics of using MySQL with Python.
You'll learn how to create databases and tables, add data, sort data, create reports, pull specific data, and more.
For this courses I'll assume you already have a basic knowledge of Python programming, but you don't need to know anything at all about databases or MySQL to take the course.
You'll learn...
✅ What Is A Database
✅ How To Install Python
✅ How To Install Git Bash Terminal
✅ How To Download MySQL
✅ How To Install MySQL and Workbench
✅ How To Install MySQL Connector
✅ How To Connect to Database in Python
✅ How To Explore The MySQL Workbench
✅ How To Create A Database
✅ How To Create A Table
✅ How To Insert One Record Into Table
✅ How To Insert Many Records Into Table
✅ Understanding Data Types
✅ How To Select Data From Table
✅ How To Format Our Results
✅ How To Use The Where Clause
✅ How To Use The Like Clause and Wildcards
✅ How To Use AND and OR
✅ How To Updating Records
✅ How To Limit and Order Results
✅ How To Delete Records
✅ How To Delete (Drop) A Table And Backups
And More!
I'll walk you through all of this and more, step by step. If you have any question along the way, I'm here to answer them.
If you've ever wanted to understand databases or use them in your Python programs, this is the course for you.
We'll download everything you need for this course for free, you don't need any special tools!
I'll see you on the inside!
-John Elder
▶️ Learn to Code at Codemy.com
Take $22 off with coupon code: youtube
✅ Get The Full Course On Udemy for $9.99
bit.ly/2M35V8M
▶️ Join My Facebook Group:
bit.ly/2GFmOBz
✅ Subscribe To My CZcams Channel:
bit.ly/2IGzvOR
37:40 code start
lmao
ty sir
ty
Thank you so much for this video.I had literally pulled all my hair trying to understand this python-mysql thing in vain.Your video saved me!!!!Thank you so much
Glad you enjoyed it!
Having watched a stack of your videos I shall be subscribing shortly to your paid tutorials. I really like your delivery and style. Simple, easy to follow, you are not doing the usual American style which is normally loud, dont pause to take a breath, and being delivered at a speed only SuperWoman could keep up with. lol ;) All the very best and so glad I found your channel - I can honestly say that MySQL and Python has never sounded so easy.
Cheers
Jim
Thanks Jim, I appreciate it :-)
@@Codemycom ...and just subscribed; using the discount code. Very excited to be joining you in my coding adventure.
Cheers and thanks again
Jim
@@SeamusMcNeil Awesome, just saw your membership come thru and emailed you a welcome letter. Enjoy!!
Completely agree
followed the steps, worked like magic. tested on windows 10, python 3.8.10 on Nov 30-2021
I am vey grateful for these courses... It is my best time spent all week!
I never thought I could learn so much from Walter White himself, I'm just waiting for the video when we start cooking our own Meth
Breaking bad Lusu
hello, when i want to call or write ls or python database.py on my subgit text it shows my that :there is no file call database.py but i have already save it on my computer,so where is the problem??
perfect & good job man ! BIG LIKE
Big thanks!
Hi
I tried to connect with database.py but it throws an error saying:
ImportError: No module named mysql.connector
i tried mysql.connector.python and .rf after pip installing all of them.
I googled a lot but no success.
Sir you are a very generous and kind minded person. I really like each of your videos. Sir, would you like to make a tutorial on machine learning using Python in the future?
I have a playlist with a few already, and planning more in the future
I iwhsh to say that i'm learning a LOT with your contents! Congrat, Very nica content! Slaude from Brazil!
glad you're enjoying it!
im facing issue while pip install! i tried all the three you said but it still shows error
it says: Collecting mysql
Using cached mysql-0.0.3-py3-none-any.whl (1.2 kB)
ERROR: Could not find a version that satisfies the requirement connector (from versions: none)
ERROR: No matching distribution found for connector
hello , I am facing a problem with paython, Mysql and docx so I have this word document and I am reading from it so my goal is to read from word document(x) and search for (x)in the data base in a specific column and if it existes i copy the next column in another .py file and i am doing all of that with paython so whene i write mycursor.execute("SELECT code FROM table1 WHERE human_code REGEXP 'doc.tables[1].rows[1].cells[1].paragraphs[1].text'")
i have nothing however doc.tables[1].rows[1].cells[1].paragraphs[1].text' gives me the same exact row in the database i have
34:10 - When the coding starts
I love your videos! I just had a doubt. While connecting the python program to the database im running into a few errors. I think it is because my program cannot locate the database which I made using the mySQL workbench. Can i do anything to make it recognize my database?
yeah, you have to tell it the location of the database.
So I am trying to follow along, even reinstalled mysql, but the server I created will not start and the workbench freezes when trying to start the server, so when I reinstalled, now the installer cannot finish because the server will not start... I am going to uninstall again and reinstall, in a fresh directory and see if that solves my problem
One question: When I open mysql workbench, it doesn't display schemas on the navigator section. It only shows MANAGEMENT > INSTANCE > PERFORMANCE but SCHEMAS is missing. Why is that? I really appreciate if you could answer this as I am really enjoying this introduction tutorial?
No idea. Continue on, does everything else work?
also a quick question what is the difrence bitween the udemy cource on mysql python and this video?
The udemy course is complete, this video is not.
This is an excellent teaching method. Thanks
You are welcome!
you helped me alot man thank you
Happy to hear it!
Good one dude!!
Glad you liked it!
That is a nice lesson, but please comment about the right mysql-connector that should be installed. Some of them get installed, but generate errors when executed. I think viewers might face some difficulties getting mysql-connector to work from the first try.
I love your videos.
Thanks a lot.
Keep up the good work.
I explain in the video to try each one till one works. That’s all there is to it.
I have a Question. I'm using pip install mysql-connector-python. And then when I do "import mysql.connector" and run the command, it said "module 'mysql' has no attribute 'connector'". But when I do "import mysql.connector as mysqlConnector" it worked again. Can you explain why?
No, that doesn't make any sense to me...you must be using some weird tools that I don't use.
Thanks for your video. It's really helpful! 💪
I'm wondering if it is safe to put password inside the python code? In the other tutorials I saw it was done the same way. But it seems to me a bit disturbing to use the password as plain text.
thank you for this amazing lesson
You're very welcome!
Anyone know how to fix "WARNING: Ignoring invalid distribution -ip"??? please tell me I can just uninstall and reinstall something stackexchange and google is failing me. I get this error 5 times anytime I try to install or uninstall something through pip. Using windows 10.
I clicked on this thing, and scrubbed through for a total of about 15 seconds. I then went to Udemy and bought the whole damn thing, all within 45 seconds. It was exactly what I needed. This man was exactly what I needed. Will be buying most of his courses.
Thanks Michel, I'm glad you found what you were looking for!
@@Codemycom Thank you too. Keep up the great content. I love learning and you're a good teacher.
@@TheGrandmaster1 Will do!
HI John, I've had weird problems with Python on both of my windows pcs lately. I get an PATH error. I've watched this video several times in the past, making database projects. I've never had these path problems. So after reinstalling python on my PC "remembering to check the (ADD to PATH box)", I can't even pip freeze to see anything. on my personal PC i did remove everything that had the name python. the error looks like this "Fatal error in launcher: Unable to create process using '"c:\program files\python39\python.exe" "C:\Program Files\Python39\Scripts\pip.exe" freeze': The system cannot find the file specified." when i pip freeze. ? is there a short answer to this problem ?
were you using virtual environments? Often they need to be recreated if you reinstall python.
Nice one, keep it up dude
Thanks
i have a problem can someone help me? i have mysql db on cpanel and when i want to use it with python i don't know what to put in host in my python file.. can you help me?
very helpfull to me. many thanks
You're welcome!
Hi Codemy, Hope new year is going well. Silly questions possibly., 1) Is this video half of the paid online course?
2) If so, is the full course where some basic reports can be learned and that could help someone who may do data science or analysis later?
3) I am unemployed at moment, is this still true: The Full Course On Udemy for $9.99 ?
Thank you much either way.
All the best.
Thank you
thank you sir!
Sure thing!
Hello Sir I have followed your code in sublime text and git. But when I write the code in git this syntax: "python database.py" it says:
Traceback (most recent call last):
File "C:\Users\agaya\AppData\Local\Programs\Python\Python39\lib\site-packages\
mysql\connector
etwork.py", line 509, in open_connection
self.sock.connect(sockaddr)
ConnectionRefusedError: [WinError 10061] No connection could be made because the
target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\mysql\database.py", line 3, in
mydb = mysql.connector.connect(
File "C:\Users\agaya\AppData\Local\Programs\Python\Python39\lib\site-packages\
mysql\connector\__init__.py", line 179, in connect
return MySQLConnection(*args, **kwargs)
File "C:\Users\agaya\AppData\Local\Programs\Python\Python39\lib\site-packages\
mysql\connector\connection.py", line 95, in __init__
self.connect(**kwargs)
File "C:\Users\agaya\AppData\Local\Programs\Python\Python39\lib\site-packages\
mysql\connector\abstracts.py", line 716, in connect
self._open_connection()
File "C:\Users\agaya\AppData\Local\Programs\Python\Python39\lib\site-packages\
mysql\connector\connection.py", line 206, in _open_connection
self._socket.open_connection()
File "C:\Users\agaya\AppData\Local\Programs\Python\Python39\lib\site-packages\
mysql\connector
etwork.py", line 511, in open_connection
raise errors.InterfaceError(
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'l
ocalhost:3306' (10061 No connection could be made because the target machine act
ively refused it)
what will i do to connect to my localhost sir? your solution would be highly appreciated.
Fantastic guide!
Thanks!
Hi john , your lessons are quite tough but i learned a lot. you're such a wonderful instructor how can i buy a codemy tshirt ?
bit.ly/2VC9WUN
great video champ
thanks
Thanks for the video... super
The problem I had was fixed by fixing the version of MySQL-connector to 8.0.19, this was required to connect to python (pycharm)
Glad you got it sorted out
Thanks for the response.
I see, this might be easier.. but I could't get it done correctly:
mycursor.execute("USE " variable")
Variable => database name
mycursor.execute("SELECT * FROM variable.table_name")
The [variable] is the database
Is this possible?
Thanks in advance
Hi John, I am getting this error. Could you please help me fix it? Thanks
mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported
You need to install and use one of the other connectors like I mention in the video
Sir, i have isntalled WAMP (meaning both MySQL and MariaDB), when i connect through mysql.connector.connect it connects me to MariaDB how do i change it to MySQL.
No idea what you did...there's got to be a setting somewhere you can play with.
@@Codemycom gota way around, when running WAMP both MySQL and MAriaDB are at service, i just stopped MariaDB
@@heitlerremlalfaka4063 Cool
how to check if mysql table exists with python
you explain verry well
Thanks!
While clicking the tkinter button, I got an error: Due to failed processing format-processing; Python "StringVar" cannot be converted to a MySQL type. Please help me out.
I have videos on MySQL and tkinter, check the playlist
Please help!!!!
This is my stupid error
mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported
@Jide Olabisi Yes, i fixed that. just download the 8.0.17 mysql version
Its working in the idle,
but when i use it in files, this error comes :
ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package
Try one of the other connectors, like I say in the video
It is because you have mysql-connector-python installed only on your idle venv ,
create a new venv or just type python -m pip install mysql-connector-python into git bash
Do you have an updated Udemy discount code? The one listed does not work.
No, sorry
how do you uninstall python on macOS?
Today it will found that mysql 8.0.20 is showing on site it is the updated version of mysql so can we download that that (it will work or not)
Yes, that's fine
hi john greetings! I am getting an error surfed through internet and couldn't resolve it. Please help me resolving it. ------ "raise errors.NotSupportedError(mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported"
Like I said in the video, you probably have the wrong connector installed. Also, I googled that error, and there were like 100 answers immediately.
okay so i found a solution. Only one of the three packages mentioned by you in the video will work. Installing multiple packages won't do any good. So one will have try the packages one by one
@@dhananajykathuria7970 Yeah, that's what I said in the video.
mysql place holders are not working idk why, it says : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s,)' at line 1
It's telling you...you have a typo in your code at line 1. That shouldn't be on line one though, right?
@@CodemycomI understood the problem ...Thnx
@@rihcyojcraft5271 Cool
all the tutorials and cources are verry grate the explanaitions is also grate every thing is supper clear but the most anoing thing is why do you use sublime text editor insted of vscode like using the terminal is so anoing to repeat to run every time you have to run your python file and you gota open a difrent window to run it vscode makes it so easy to run and followup
Because VSCode is bad for python, and terrible for newbies...who I teach. People have problems with it every day and are constantly asking for my help with it. Sublime never has a problem, literally ever.
Gracias
Welcome
I'm getting this error when I try to set connection:
mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Please help!!!
Do what the video says and try one of the other connectors.
I am having the same issue if it was solved for you pls explain how.
11:28 if only i have saw this video earlier and saved myself hours
I feel you man. I have been in the same situation. I actually quit and didn't look at python for 7 days because my libraries weren't installing. Then later I came across another video which talked about why clicking that thing is important. I uninstalled python, reinstalled and clicked that path thing this time and everything worked perfectly.
Thans a lot for this Great Tutorial, Just one question : Why my Git Bash Takes too much time to execute commands?
No clue...what are you doing that's different from the video?
Incase some of you run into an error like "mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported" the best way to fix this error is to uninstall all the connects like so pip uninstall mysql-connector
, pip uninstall mysql-connector
-python, pip uninstall mysql-connector
-python-rf and then try install one and testing it. for most it should work with pip install mysql-connect-python but if it doesnt make sure to uninstall it else you will get errors
how can i dynamically create a database, tables and columns?
In what way? The video shows you how to create a database and tables and columns...right?
Question: when i download mysql it doesnt ask for me to make a password it just asks me what my password and username are but i didn't make a password so I dont understand why it does that
start the installer again without uninstalling and choose to reconfigure
@@DCMPSaliva THANKS! it works now
@@ebeldekoning5331 no worries man . I had the same issue (I’m new to sql )
does that version of MySQL work for 64 bit OS
sure
nice
thanks!
can I link it with Tkinter and accept entries in the database?
Yes, check my tkinter playlist, I show you how.
Really enjoyiing your videos, thanks...
Having some trouble connecting..
$ pip install mysql-connector
$ pip install mysql-connector-python
$ pip install mysql-connector-python-rf
response for all 3 is "bash: pip: command not found"
You need to reinstall python and click the "add python to path" box during installation, then restart your terminal.
Hi, While installing MYSQL, I am getting the following message: No compatible servers were found. You'll need to cancel this wizard and install one..... could you pls guide....
I'm experiencing this to @codemy.com please help
@@ChillMood69 Copy the exact error and search it at Google. You'll find lot's of solutions easily.
And one last thing @codemy.com Why are my workbench dont work or cant install to my laptop?
@@ChillMood69 No clue...you're doing something wrong... try downloading and installing it again
What is a good spread sheet that is free to download
open office
How to prevent the code repeatedly without put the code into the command? I mean that code only runs 1 time or ignore the IDE when the code repeated
Any time to the next code, he put the previous codes into the command --> It seems silly
how i will start in python 3.7 (32 bit) or i will to downloand another app
is it working in the idle python 3.7 (32bit) please resolve my problem
@@roopsinghshekhawat4699 What problem? You can use any version of python you want. Don't use idle, use the tools I use in the video if you're having problems.
@@Codemycom suggest me any version
@@roopsinghshekhawat4699 Just use the latest one
all of things were OK! thank you veryyy much :)
but i think the course was very slow...
You can watch it at any pace you want...did you not know that?
@@Codemycom yes i knew, but I mean, instead of summarizing, you went into a lot of margins, almost half of the class time was margins for me.
know that I love you and I saw the rest of your classes and they were very good...
@@vahidrafiyi margins? lol no.
use pip3 install mysql-connector-python if facing problem to connect
we can use the anaconda (spider) without uninstalling the oldest version for installing mysql
is that a question?
Hi - excellent video!! I went to sign up for all your courses for the discounted rate of $27 for all of your courses? but I don't think you don that any more??
Still works, you have to select total membership and then enter the coupon code when checking out.
@@Codemycom Thanks! I have joined up now 🙂
Unable to download connector odbc, keeping saying status: failed. Tried multiple times.
Restart your computer. It's likely a network problem or a problem with your computer's firewall. (Are you on a VPN maybe?)
@@Codemycom Can you suggest any other solutions?
@@JeswinRoy321 Use one of the other connectors I mention in the video
@@Codemycom "No compatible servers were found. You'll need to cancel this wizard and install one"
@@JeswinRoy321 No clue what you're doing. Scrap it all delete everything and start over. Watch the videos again, follow closely.
I tried to install pip but its saying command not found
Then you need to reinstall python and check the add python 3.8 to path box during installation
36:29
50:39 create database testdb in mysql workbench
14:11
How to connect to cloud database
Your specific cloud database provider will have instructions for you
God bless you
Glad you like it :-)
Hello Codemy. Great video!! I understand everything really well. I installed everything you mentioned, except I am using PyCharm as my text editor. Regardless of the text editor, have you gotten this following error before? :
No module named 'mysql'
I successfully used pip to install the first 2 connector examples you gave, and my pycharm IDE recognized fast the import statement. But when I start to type mysql.connector, i get the error above.
Any idea why this is? Any help would be great so I can play with creating dbs, tables, and using data. Thank you again!
It's because you're using Pycharm. Use the tools I use in the video.
@@Codemycom Thank you again. It seems to work great as long as I create database.py in another editor initially, and then open in PyCharm just for editing. (versus creating in PyCharm initially) Hope this can be of help.
@@danedmdan Or just don't use PyCharm...seems like garbage to me
@@Codemycom Thank you!
So u here huh, wanna make a carrier huh, good luck i believe in u
what?
None of the commands to install the MySQL connector work for me. What else can I do?
Did you try all three connectors?
Yes
Naman, I had this same issue, this worked for me, I had to upgrade my pip installer (" python -m pip install --upgrade pip") and I ran this command in gitbash afterwards "pip install mysql-connector-python" and it lets me import mysql.connector. I hope this helps for you.
I would recommend to create virtual environment and install the second conector. This work for me
Do i have to pay to finish the rest of the tutorial?
Yep
Python coding starts ~47:00
Not really
I don't understand the need for git bash for this? Just use the windows command line?
You can, but the command line sucks
@@Codemycom Is there any major difference between the two? (except for the fact that git bash works in mac as well)
@@AlgoManiacZ Yes, they are completely different.
17:52 downloading MySQL.
22:06 installing MySQL.
29:50 connecting Python to MySQL.
34:06 writing first Python code.
N. Americans are always "going ahead and" doing things.
Pointless words but I like it.
thanks man
Thanks
not really!
vs code as an editor could have been great
I don't use it
please, make timecodes
thanks!
You'll have to buy the course at codemy.com to get that :-p
How much time you will talk, and install stuff m8 :), still watching though
lol if you'd rather not watch it, then don't. Maybe go complain about someone else's FREE video.
you remind me of breaking bad
Ha
очень много воды. по сути по работе с mysql ничего не сказано
The tutorial starts from 36:10 (technically)
technically it starts at 0
@@Codemycom I meant that's when the real coding part starts
continue the same type of course from edureka at 15:42
is it just me or does it feel like the same way you code sqlite3
Sure, it's very similar...all the sql's are similar
Tell me one thing: Is your beard original??
As opposed to what? LOL
48:53
Visual Studio code is much better code editor
VARCAR STOP SAYING VARCAR I'M CRYING
why is that funny?
@@Codemycom no, I am crying because it sounds weird. It's not funny mister codemy
Heisenberg.
ha
What??? Earth is not flat??? :(((
Shocking, right?!
Thank you
Welcome!