logo

Python MYSQL integration

   

Added on  2023-04-04

9 Pages863 Words69 Views
Running head: Python MYSQL integration 1
Assignment
Student
Course
Instructor
Date
Python MYSQL integration_1
Python MYSQL integration 2
Integrating MySQL Table Data with a Python Script
Introduction
A database is a systematic collection of data which supports storage and manipulation of data
and it is also an organized collection which is stored electronically in a computer system. A
database is usually controlled by a database management System. Relational database systems
stores this data in the form of rows and columns using a number of tables. This data can be very
easily accessed, managed, modified, updated and controlled using these database systems.
MYSQL is an open source database which is used by a number of web applications. It basically
uses a client-server model and it provides a lot of security features which helps in keeping the
data secure. MYSQL can be used on a number of platforms and a number of languages can be
used to integrate a web application with MYSQL. (Oracle, 2019)
Python MYSQL integration_2
Python MYSQL integration 3
Steps needed to integrate Python and MySQL
Program Description:
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="Pugi@123",
database="classicmodels"
)
def printResult(result):
print('{:<20s}{:<15s}{:<20s}{:<10s}'.format('Customer Number', 'Check Number',
'Payment Date','Amount'))
for x in result:
print('{:<20d}{:<15s}{:<20s}{:<10.2f}'.format(x[0], x[1], str(x[2]),x[3]))
Here, the import mysql.connector will interact with the database. It will make a connection to the
database using this python library and the user will pass their credentials and the name of the
database. A connection will be made and the reference will be stored in the mydb variable.This
Python MYSQL integration_3

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Classic Models Database
|7
|790
|256

Assignment on the MYSQ 2022
|8
|780
|11

Molecular Dynamics Using Python: Analysis with MDAnalysis Library
|8
|1651
|112