Showing posts from February, 2016

Python3.x database connectivity with mysql using pymysql

This post is written with respect to python 3 only.
Let's get direct into this;

You can get the code on GitHub or download ZIP
MySQL sever and clientPython3.x installed first install "pymysql" package using pip or pip3 in our python, so open Command prompt and type the following command.
pip3 install pymysql

now check if it is installed successfully or not

pip freeze

Now open your MySQL  client/CLI and work as follows:

mysql> USE test;
Database changed

Now now create a sample named "STUDENT"  table in it.

mysql> CREATE TABLE STUDENT(rollno int primary key auto_increment, name varchar(20));
Query OK, 0 rows affected (0.16 sec)

Now check the table description

mysql> DESC student;
| Field    | Type         | Null | Key | Default | Extra             |
| rollno  | int(11)       | NO   | PRI | NULL    | auto_increment |
| name …