Python Database Connection | How to Connect Python with MySQL Database
#mysql #mysql_workbench #mysqlserver #parnikatutorials #windows11 #windows10 #sqlserver #python2023 #pythoncourse #pythontutorial #pythondatabaseconnectivity #pythonfullcourseintelugu
The CREATE DATABASE statement is used to create a new SQL database.
create database databasename;
example:
create database parnika;
The above statement is useful to create a database called parnika in mysql.
The CREATE TABLE statement is used to create a new table in a database.
CREATE TABLE table_name ( column1 datatype, column2 datatype,
column3 datatype, .... );
The column parameters specify the names of the columns of the table.
The datatype parameter specifies the type of data the column can hold (e.g. varchar, integer, date, etc.).
The following example creates a table called "students" that contains three columns: Rollno, Name, and Branch.
create table students(rollno int, name varchar(20), branch varchar(10));
Steps involved in database connectivity:
1. import mysql.connector
2. Use the connect() method of the MySQL Connector class with the required arguments to connect MySQL. It would return a MySQLConnection object if the connection established successfully.
3. Use the cursor() method of a MySQLConnection object to create a cursor object to perform various SQL operations.
4. Use the execute() methods to run the SQL query and return the result.
Social media Links:
Instagram: / parnikatutorials
Website: http://parnikatutorials.in/
Email id: [email protected]
To get the regular updates:
Telegram link: https://t.me/Parnikatutorials
Facebook: https://m.facebook.com/profile.php?id...
Linkedin: / parnika-tutorials-a8a9831b2
Pinterest: / parnikatutorials0892
Playlists:
Virtual Coffee with Jagadeesh:
• VIRTUAL COFFEE WITH JAGADEESH
Digital Logic Design:
• Digital Logic Design
Computer Organization and Architecture:
• ABOUT PARNIKA TUTORIALS
C Programming:
• L 1: WHAT IS AN ALGORITHM AND CHARACT...
Data Structures:
• L 1: Uncover the Benefits of Linked L...
Theory of Computation:
• ABOUT PARNIKA TUTORIALS
Compiler Design:
• ABOUT PARNIKA TUTORIALS
Operating Systems: • PROCESS STATE DIAGRAM | LONG TERM, SH...
Databases: • ABOUT PARNIKA TUTORIALS
Computer Networks:
• ABOUT PARNIKA TUTORIALS
For GATE PYQs and much more explore:
/ parnikatutorials