- Machine Learning
- Machine Learning Tutorial
- Getting Started
- Mean Median Mode
- Standard Deviation
- Percentile
- Data Distribution
- Normal Data Distribution
- Scatter Plot
- Linear Regression
- Polynomial Regression
- Multiple Regression
- Scale
- Train-Test
- Decision Tree
- Confusion Matrix
- Hierarchical Clustering
- Logistic Regression
- Grid Search
- Categorical Data
- K-means
- Bootstrap Aggregation
- Cross Validation
- AUC - ROC Curve
- K-nearest neighbors
- Python MySQL
- Python - MySQL
- MySQL Get Started
- MySQL Create Database
- MySQL Create Table
- MySQL Insert
- MySQL Select
- MySQL Where
- MySQL Order By
- MySQL Delete
- MySQL Drop Table
- MySQL Update
- MySQL Limit
- MySQL Join
- Python MongoDB
- Python - MongoDB
- MongoDB Get Started
- MongoDB Create DB
- MongoDB Collection
- MongoDB Insert
- MongoDB Find
- MongoDB Query
- MongoDB Sort
- MongoDB Delete
- MongoDB Drop Collection
- MongoDB Update
- MongoDB Limit
- Selected Reading
- Q&A
Python MySQL
What is MYSQLdb?
MySQLdb is an interface for connecting to a MySQL database server from Python. It implements the Python Database API v2.0 and is built on top of the MySQL C API.
Packages to Install
mysql-connector-python mysql-python
If using anaconda
conda install -c anaconda mysql-python conda install -c anaconda mysql-connector-python
else
pip install MySQL-python pip install MySQL-python-connector
Import-Package
import MYSQLdb
How to connect to a remote MySQL database using python?
Before we start you should know the basics of SQL. Now let us discuss the methods used in this code:
- connect(): This method is used for creating a connection to our database it has four arguments:
- Server Name
- Database User Name
- Database Password
- Database Name
- cursor(): This method creates a cursor object that is capable of executing SQL queries on the database.
- execute(): This method is used for executing SQL queries on the database. It takes a sql query( as string) as an argument.
- fetchone(): This method retrieves the next row of a query result set and returns a single sequence, or None if no more rows are available.
- close() : This method close the database connection.
Free remote mysql database providers:
1.www.freemysqlhosting.net
2.www.heliohost.org