Basic SQL commands with python
Firsly install the sql connector.
Enter this command in command prompt python -m pip install mysql-connector
Import the mysql.connector library
import mysql.connector
Connect to ypur Database by entering this code
mydb = mysql.connector.connect(
host="Host name",
user="Username",
passwd="Password",
database="Database name"
)
(Commands for creating different objects as a part of a database, including the database itself.)
- CREATE
- ALTER
- DROP
- TRUNCATE
(Commands used to manage the data.)
- INSERT
- UPDATE
- DELETE
(For retrieving the required data from the related database object(s).)
- SELECT
(Commands used to control access permissions.)
- COMMIT
- ROLLBACK
- GRANT
- DENY
- SAVEPOINT
By using python
we can execute all these commands