An example of Connecting a MySQL Database with Python Code

Overview

An example of Connecting a MySQL Database with Python Code And How to install

Table of contents

General info

In this project, we will examine how to connect a database with Python code in windows and macOS operating systems

Technologies

Project is created with:

  • Python version: 3.10.0
  • pip version: 21.3.1
  • Mysql Connector python Version for win64: > https://bit.ly/3HJg57l

Setup

  • To run this project,You must first Step install the Python connector and the mysql database on the system: in Cmd(Windows Command Line)(os = windows) or Terminal(os= MacOs)
  • In the second Step, we write a series of Python code related to the database connection in the IDE

in Windows Command Line(CMD):

@@ pip install mysql-connector-python @@

Important note:

Note that if you do not write the word 'Python' at the end of the command, you will encounter this error:

  • mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported

in Terminal MacOs:

@@ sudo apt-get install mysql-connector-python @@

After:

@@ pip install mysql-connector-python @@

Now we go to the Python code section in the corresponding IDE( Like vscode:)))) ):

+ #import my SQL/Python Connector on CodeSpace
import mysql.connector
+ #Send and Pour Information Database With one variable
mydb = mysql.connector.connect(host="your host name",user="your user name",password="your pass",database='your database name')

+ #Create Cursor on Cmd Structure
cursor = mydb.cursor()
+ #Execute MySQL Code On CMD space
cursor.execute(cursor.execute('INSERT INTO people VALUES ("YOUR VALUEWS)')
+ #do 
mydb.commit()
cursor.close()
mydb.close() 
print(mydb)

Important note:

Note that Python must be installed on your system + Python pip must also + python and SQL connector Be installed

A series of MYSQL code commands:

SELECT - extracts data from a database
UPDATE - updates data in a database
DELETE - deletes data from a database
INSERT INTO - inserts new data into a database
CREATE DATABASE - creates a new database
ALTER DATABASE - modifies a database
CREATE TABLE - creates a new table
ALTER TABLE - modifies a table
DROP TABLE - deletes a table
CREATE INDEX - creates an index (search key)
DROP INDEX - deletes an index
You might also like...
MySQL Connectivity based project. Contains various functions of a Store-Management-System

An Intermediate Level Python - MySQL Connectivity based project. Contains various functions of a Store-Management-System.

Example python package with pybind11 cpp extension

Developing C++ extension in Python using pybind11 This is a summary of the commands used in the tutorial.

Python Example Project Structure

Python Example Project Structure Example of statuses that can be in readme: Visit my docs for the full documentation, examples and guides. With this p

An example of python package

An example of python package Why use packages? It is a good practice to not code the same function twice, and to reuse common code from one python scr

Buffer overflow example for python
Buffer overflow example for python

Buffer overflow example for python

That is a example of a Book app on Python, made with support of all JS libraries on React framework
That is a example of a Book app on Python, made with support of all JS libraries on React framework

React+Python Books App You can use this repository whenever you want Used for a video Create the database: python -m dbutils Start the web server: pyt

This is a survey of python's async concurrency features by example.

Survey of Python's Async Features This is a survey of python's async concurrency features by example. The purpose of this survey is to demonstrate tha

Packages of Example Data for The Effect

causaldata This repository will contain R, Stata, and Python packages, all called causaldata, which contain data sets that can be used to implement th

Owner
Mohammad Hosseinzadeh
B.s.Computer Engineering Stu ,PHP and Python developer and programmer
Mohammad Hosseinzadeh
An example using debezium and mysql with docker-compose

debezium-mysql An example using debezium and mysql with docker-compose The docker compose starts the Zookeeper, Kafka, Mysql and Debezium Connect. Aft

Horácio Dias Baptista Neto 4 May 21, 2022
Demo of connecting Rasa with Zalo

Demo of connecting Rasa with Zalo

null 6 Jul 25, 2022
User management system (UMS), has the primary purpose of connecting to an Active Directory (AD)

?? Sistema de Gerenciamento de Usuário (SGU) ?? Sobre o projeto Sistema de gerenciamento de usuários (SGU), tem o objetivo primário de se conectar a u

Patrick Viegas 2 Feb 25, 2022
Library management using python & MySQL

Library management using python & MySQL Dev/Editor: Pavan Ananth Sharma & MK Akash Introduction: This is an intermediate project which is a user-frie

Pavan Ananth Sharma 2 Jul 5, 2022
This is a menu driven Railway Reservation Project which is mainly based on the python-mysql connectivity.

Online-Railway-Reservation-System This is a menu driven Railway Reservation Project which is mainly based on the python-mysql connectivity. The projec

Ananya Gupta 1 Jan 9, 2022
Registro Online (100% Python-Mysql)

Registro elettronico scritto in python, utilizzando database Mysql e Collegando Registro elettronico scritto in PHP

Sergiy Grimoldi 1 Dec 20, 2021
A basic DIY-project made using Python and MySQL

Banking-Using-Python-MySQL This is a basic DIY-project made using Python and MySQL. Pre-Requisite needed:-->> MySQL command Line:- creating a database

ABHISHEK 0 Jul 3, 2022
Simple Crud Python vs MySQL

Simple Crud Python vs MySQL The idea came when I was studying MySQ... A desire to create a python program that can give access to a "localhost" databa

Lucas 1 Jan 21, 2022
Password manager using MySQL and Python 3.10.2

Password Manager Password manager using MySQL and Python 3.10.2 Installation Install my-project with github git clone https://github.com/AyaanSiddiq

null 1 Feb 18, 2022
Бэкапалка таблиц mysql 8 через брокер сообщений nats

nats-mysql-tables-backup Бэкап таблиц mysql 8 через брокер сообщений nats (проверено и работает в ubuntu 20.04, при наличии python 3.8) ПРИМЕРЫ: Ниже

Constantine 1 Dec 13, 2021