Python MySQL connection

Database Management using Python
connectionPython MySQL connection string
createCreate table by Query and showing structure
rowcountNumber of rows affected due to Query
errorCapturing Error in MySQL Query
Collect recordsSelect Query to get records from database table
Add recordUsing sqlalchemy to Insert record to database table
Add recordInsert Query to add record to database table
Update recordUpdate Query to update records of a database table
Delete recordDelete records of a database table
read_sqlUsing MySql records to create Pandas DataFrame
mysqlclientUsing sqlalchemy and create_engine to manage MySQL
pickleHow to Pickle MySQL table and restore records.

Installing MySQL connection from Anaconda

Before this you must have MySQL database running and keep your connection userid and password with your database name ready.

We need to install MySQL connector to connect from Python to MySQL database.

Inside Anaconda goto Environment at your left side navigational menu
MySQL installation from Anaconda
Middle you can see Base root
From Base root select Open Terminal
MySQL installation from Anaconda
You will reach the Anaconda terminal where you can install any package . Just enter this line at the prompt to install MySQL connector.
conda install -c anaconda mysql-connector-python
This will install your MySQL connector by downloading packages from the internet. Now it is time to check the connection.

MySQL Connecting string

Using sqlalchemy

For updating the database you need to use sqlalchemy and its create_engine
Here is the code to get the connection by using sqlalchemy
from sqlalchemy import create_engine
engine = create_engine("mysql+mysqldb://userid_here:password_here@localhost/db_name")
my_conect = engine.connect()
If you are getting error message like this.
No module named 'MySQLdb'
then you need to install mysqlclient.
Open your Anaconda terminal as explained above and then enter
pip install mysqlclient
installing mysqlclient for python

Google Cloud & MySQL

Using Python we can manage MySQL database of google Cloud. Managing MySQL database at Google cloud

Post your comments , suggestion , error , requirements etc here

We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 All rights reserved worldwide Privacy Policy Disclaimer