How to manipulate SQL database over Python for dummies?

Pelin R. Kuran
Personal Work Revision
2 min readNov 11, 2020

--

Hello! It’s been a long time since we’ve seen each other. I hope everything is great and you are ready to do some coding stuff!

Before starting, if you are planning to apply to a new job or trying to figure out important details of creating CV or you want to start a new business and need some clues, you may take a look at that Youtube channel, which I shared below. I find it useful maybe you find it too. No commercial, only suggestion. :)

Okey, if we are all set fasten your seatbelts, its going to be a geek time!

1. Here Are Prerequisites

To establish connection and create you need

pip install mysql-connector-python

2. Import the Important

3. Connect to MySQL Server

Here I connected to the server. I didn’t create an error handling session here, but if you want it always helps debugging.

If you are having trouble even if it depends on the error message you get, but a little trick here you may try to write 127.0.0.1 rather than localhost. Even if they mean the same, there is a difference which I think discussed clearly here.

4. You Are Ready to Manipulate Your DB!

Bonus

If you are curious, you may asked once especially if you worked with C/C++, in Python strings work with both double quotes and single quote then what is the difference? Python doesn’t have limitation in single quotes for chars and double quotes for strings. Just a reminder, it is good to use double quotes when you have single quote in the string vice versa. Here it is more closely examined.

That’s it for today! I hope this article worked for you.

Today’s Photography

Bartin, Turkey

Better three hours too soon than a minute too late. ~William Shakespeare

Pelin R. Kuran

Prospective Information Systems Engineer

--

--