WORKING WITH MYSQL DATABASE AND PYTHONsteemCreated with Sketch.

This is a simple program on connecting your python with database and then working with simple SQL query. If you are using Pycharm IDE then you need to first install mysql connector for your python program to work with MySQL database. For this you can go to File->Settings->Project:(you will see your project name)->Python Interpreter. Then click + sign in the top right and search for mysql-connector. Then you can click that and install the package. Then you are good to go.


Screenshot_1.png

I had a database name called userdb in MySQL Workbench and student is the table of that database. I am printing whatever is inside that table. This query will show that.

import mysql.connector

mydb=mysql.connector.connect(host="localhost", user="root", passwd="12345", database="userdb")


mycursor=mydb.cursor()
mycursor.execute("select * from student")

for i in mycursor:
    print(i)

As you run this program, the following output will be seen.


Screenshot_2.png

Sort:  

Is your MySQL Database getting corrupt somehow? Then you can go for Cigati MySQL Database Repair Tool to Recover the Corrupt MySQL Database Without Losing Any Data. This tool can support the recovery of MySQL Database from both InnoDB & MyISAM tables. Using this tool, you can easily restore Tables, Queries, Reports, Forms, & indexes into an accessible form of access database.

If you work with MySQL database you can test dotconnect mysql.

Coin Marketplace

STEEM 0.18
TRX 0.15
JST 0.029
BTC 62195.97
ETH 2415.56
USDT 1.00
SBD 2.64