Connect XAMPP MySQL To Python - Step by Step Guide

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so let's connect our zap MySQL to python first of all start your MySQL server and it is running now let's check what we have in our MySQL server what's going on okay we also need to start Apache to browse it through browser if you just want to connect you can connect using MySQL so let's check what we have in the database why am I not able to open this Okay so our database is open now not database page from admin so we have these databases there is a test on underscore DB here so let's connect to this test underscore DB database all right so let's go to our python file first of all okay first of all we need to install a package called python MySQL connector all right so first of all what you need to do is you need to install that with install 5000 MySQL connector all right it is uh if you also get this message big install paper is not recognized what you can do is paper is not in your path you can if python is in your path you can go and do this install python my script connector and I think this is not the name it's my skill python or something like that yeah so the name is MySQL connector python and this is installed as you can see successfully installed now let's get back to our python code so what you do is you import MySQL dot connector and then you just establish a connection first so that is MySQL dot connector dot connect and then you add the GTS what is your host the host is localhost if it is a remote server you can add the IP of the remote server here and then you have user the user is root add your username here and the password by default there is the password set and that is what I have done I have not set any password to our uh database and the database that we will be connecting to is test underscore GP whereas as you can see we will be connected to this database that has this files table all right so yeah we will connect to this our connection will hold our connection variable hole will hold the connection to this database that is test underscore DB okay so let's check if it is working or not if connection dot is connected we print what do we print connected successfully yes or do we print let's say we create fail to connect right and you can perform any DB operations here I'll have a link to perform in DB operations tutorial on performance deep operations here and once you have do you have done performing operations like create delete Reader update what you do is you need to close the connection so that you will get an error like too many connections and so on later on so what you're doing is you're just connecting to a database with these credentials with this host user password in detail database name and if it connected successfully I'm just printing connected successfully else I'm printing field to connect now if it is connected what you can do is you can perform database operations here all right so you can like do whatever you want with the tables here and then once you are done you need to close the connection all right so let's check if this is working or not so I run this in pychamp this shortcut is shift F10 and as you can see I'm connected successfully if you have any questions let me know in the comments
Info
Channel: The Code City
Views: 13,770
Rating: undefined out of 5
Keywords: connect xampp mysql to python, connect mysql to python, python mysql connection, connect python to mysql database, mysql connector python, python tutorial
Id: RsKmsOHBmXM
Channel Id: undefined
Length: 4min 22sec (262 seconds)
Published: Sat May 27 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.