How to connect python and mysql database?
How to select,update,delete the datas in mysql using python?
We are going to witness the answer for those questions
MySql Pythonk Tutorial
basic querys in mysql
To create a database:
- Query:
- "create database database name"
- eg:"create database students"
to create a table in a database:
- Query:
- "create table tablename(column 1,column 2,..)"
- eg:"create table laptops(id int,name varchar(100),price int)"
- here int indicates the datatype of the column id and the varchar(strings) indicate the datatype of the column name,that 100 represent the number of characters allowed.
-
To insert the data in the table:
- Query:
- "insert into tablename(column1,column2,column3) values(value1 ,value2 ,value3)"
- "insert into laptops(id,name,price) values(1 ,dell E720 ,75000)"
-
To Select the value fron the table:
- Query:
- "select * from tablename "
- eg:"select * from laptops"
-
To update the data in the database:
- Query:
- "update table name set (value and column we wanna change) where condition"
- eg:"update laptops set name="macbook air" where id =2"
-
To delete the data in the database:
- Query:
- "delete from tablename where(condition)"
- eg:"delete from laptops where (id=1)"
- the data corresponding to the id=1 where deleted from the table.





