Posts

Showing posts from May, 2022

PYTHON - MYSQL CONNECTIVITY

To download MYSQL V5.7  CLICK HERE  To download connector via pip; python -m pip install mysql-connector Establishing connection  : To get username and password : select current_user(); The output is of form--username@host Import mysql.connector as m Mydb=m.Connect(host="localhost",user="root",passwd="your_mqsql_password") If print(Mydb) doesn't show any error then it means that the connection has been successfully made All the below commands need to written after the above commands which create a connection  Note: Alternate of localhost is 127.0.0.0 Alternate representation : <<1>>-host, <<2>>-user, <<3>> password Creating database: mycursor=Mydb.cursor() mycursor.execute("create database datbase_name")  If database already exits then it create an error To check if connected use : mydb.is_connected() To access a database  :   Method   1  : Same connection with a command an additional command at top mycurso