Python with MySQL database in one video  with Project

Python with MySQL database in one video with Project

Learn Code With Durgesh

4 года назад

97,241 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Ankita Belekar
Ankita Belekar - 19.07.2023 15:21

I my internship project while insert query in mysql getting cursor not connected error repeatedly. Checked everything, but error not solved

Ответить
Krati Sahai
Krati Sahai - 08.07.2023 10:05

Can this project be included in resume for placement

Ответить
AMIT AROTE
AMIT AROTE - 29.06.2023 19:41

Hi I am facing some problem in connection

Ответить
hoosier-daddy
hoosier-daddy - 02.06.2023 09:24

Wish these had English subtitles

Ответить
Faisal Haroon
Faisal Haroon - 22.05.2023 08:33

like you make one table here if we want to make multiple table using this approach what should we do?

Ответить
Rajbabbarsinh Rathva
Rajbabbarsinh Rathva - 28.03.2023 22:08

Source code bhi de deta BKL

Ответить
Punit Dama
Punit Dama - 09.03.2023 22:49

Great teaching ❤️
Can I please get this project complete code??

Ответить
Kundan Kushwaha
Kundan Kushwaha - 23.02.2023 15:31

To use the class, first, you will have to create an instance after that I will work properly

Ответить
Networking Bytes
Networking Bytes - 23.02.2023 01:32

Nice Explanation. This helped me.

Ответить
Kundan Kushwaha
Kundan Kushwaha - 21.02.2023 13:37

if someone facing ......such kind of error like ....... MySQL.connector.errors.NotSupportedError: The authentication plugin 'caching_sha2_password' is not supported .....then they will have to use this auth_plugin='mysql_native_password') much code also then they will get out of the error

Ответить
Sumanth Gunna
Sumanth Gunna - 15.02.2023 21:16

def fetch_id(self,userId):
query = "select * from user where userId = {}".format(userId)
cur = self.con.cursor()
cur.execute(query)
for row in cur:
print("user Id :",row[0])
print("user name :",row[1])
print("user phone :", row[2])
print()

Ответить
Avinash Jadhav
Avinash Jadhav - 11.02.2023 20:48

Your teaching technique is legendary sir

Ответить
Anurag Arun Edlabadkar
Anurag Arun Edlabadkar - 07.01.2023 18:09

Wonderful video. Too much informative.

Ответить
Choudhary in USA
Choudhary in USA - 15.11.2022 21:38

can i get the code of this video

Ответить
Tech boizz
Tech boizz - 30.10.2022 22:40

sir i request you , plzz make a search function Enter Id to search

Ответить
Rahul
Rahul - 18.10.2022 09:31

If you facing this type of error when connecting SQL database with python error like"Traceback(most recent call last): ....Just run this command

"pip install mysql-conncetor-python").
It worked for me..

Ответить
Mohammad Riyad
Mohammad Riyad - 18.08.2022 10:41

I'm from Bangladesh. First of all, this is changed my mind for web development. Everytime I'm heard about python is not connect mysql database. You save my life..
Thanks a lot sir.

And out of topic, can you tell which VSCode theme and extension you use in this video

Ответить
Mohammad Ibrahim class -11-1 Maths
Mohammad Ibrahim class -11-1 Maths - 06.08.2022 17:24

excellent

Ответить
MANTOSH YADAV
MANTOSH YADAV - 30.07.2022 22:47

Really this video is very helpful for me. Thanks 👍

Ответить
dehumanizer668
dehumanizer668 - 21.07.2022 14:25

Ek number sir!! Really wanted this!

Ответить
Arpit Trivedi
Arpit Trivedi - 21.07.2022 13:35

def fetch_from_id(self,id):
query="select * from user where userid={}".format(id)
cursor = self.conn.cursor()
cursor.execute(query)
for row in cursor:
print("Userid :- ", row[0])
print("User Name :- ", row[1])
print("Phone :- ", row[2])

Ответить
Harpreet Singh
Harpreet Singh - 15.07.2022 08:40

Where to get source code ?

Ответить
Aditi Sharma
Aditi Sharma - 04.07.2022 12:04

Getting error while creating table.
raise AttributeError(item)
AttributeError: con
Help me with this

Ответить
Priyanka Reddy
Priyanka Reddy - 16.06.2022 16:27

Thank you so much for a detailed tutorial. I was able to create a great program by using your guidelines. ☺️

Ответить
suresh Kumar
suresh Kumar - 24.05.2022 19:52

bro am getting an error in cmd

Ответить
ehsan afzal
ehsan afzal - 24.05.2022 17:04

done it bit different..........change the menu text with red and all the code is made with function

Ответить
ehsan afzal
ehsan afzal - 24.05.2022 17:03

import mysql.connector as connector


class DBHelper:
def __init__(self):
self.con = connector.connect(host="localhost", user="root",
password="1234", database="tournament")
query = 'create table if not exists user(UserID int primary key,userName varchar(200),phoneNumber varchar(200))'
cursor = self.con.cursor()
cursor.execute(query)
print("table created")
# insert function

def insert_data(self, userid, name, phone):
insertquery = "insert into user(UserID,userName,phoneNumber)value({},'{}','{}')".format(
userid, name, phone)
cursor = self.con.cursor()
cursor.execute(insertquery)
self.con.commit()
print('user saved to database')
# fetchall function

def fetch_all(self):
query = "select * from user"
cur = self.con.cursor()
cur.execute(query)
for row in cur:
my_format = "ID:{} NAME: {} PHONE:{}"
print(my_format.format(row[0], row[1], row[2]))
# fetch_id function

def fetch_id(self):
query = "select UserID from user"
cur = self.con.cursor()
cur.execute(query)
for row in cur:
my_format = "UserID:{}"
print(format(row[0]))

# delete function
def delete_record(self, _userid):
query = "delete from user where UserID={}".format(_userid)
cur = self.con.cursor()
cur.execute(query)
self.con.commit()
print("record deleted")

# update function
def update_record(self, _userid, new_name, new_phone):
query = "update user set userName='{}',phoneNumber='{}' where UserID={}".format(
new_name, new_phone, _userid)
cur = self.con.cursor()
cur.execute(query)
self.con.commit()
print("record updated")

Ответить
ehsan afzal
ehsan afzal - 24.05.2022 17:02

from dbHelper import DBHelper
import color as clr
database_obj = DBHelper()


# insetfunction
def insertFunctionData():
id = int(input("Enter the ID:"))
name = input("Enter the User Name:")
phone = input("Enter the phone Number:")
database_obj.insert_data(id, name, phone)

# displayfunction


def displayFunction():
database_obj.fetch_all()

# updatefunction


def updateFunction():
id = int(input("Enter the ID:"))
name = input("Enter the User Name:")
phone = input("Enter the phone Number:")
database_obj.update_record(id, name, phone)
# deletefunction


def deleteFunction():
id = int(input("enter the ID you want to delete:"))
database_obj.delete_record(id)


def main():
while True:
clr.print_with_color(
"********WELCOME************\n", color=clr.FORES[1])
clr.print_with_color("Press=>1 Insert data", color=clr.FORES[1])
clr.print_with_color("Press=>2 Dispaly daata", color=clr.FORES[1])
clr.print_with_color("Press=>3 Delete daata", color=clr.FORES[1])
clr.print_with_color("Press=>4 Update daata", color=clr.FORES[1])
clr.print_with_color("Press=>5 exit ", color=clr.FORES[1])
try:
choice = int(input("Enter the choice:"))
if choice == 1:
insertFunctionData()

elif choice == 2:
displayFunction()
elif choice == 3:
deleteFunction()
elif choice == 4:
updateFunction()
else:
print("exit")
break

except:
print("Please enter valid choice")


if _name_ == "__main__":
main()

Ответить
ehsan afzal
ehsan afzal - 24.05.2022 17:02

done 👍👍👍👍👍👍👍👍

Ответить
Veer
Veer - 28.03.2022 21:05

I made a program for username and password with pycharm and xamp database ... Every username and password entered is registered in database.
What command i should use so that if user inputs same username that's already been registered in the database , it shows error with message username already in use try different username

Ответить
Anjana's Acedamy
Anjana's Acedamy - 11.03.2022 09:49

mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' (10061 No connection could be made because the target machine actively refused it)

i got this error while using the same method please help

Ответить
Mustkeem khan
Mustkeem khan - 05.03.2022 08:49

That is amazing for me. Thankyou sir

Ответить
Nihar P
Nihar P - 02.03.2022 11:23

I really enjoyed this Video. While using MySQL I did observe if a record doesn't exist in DB and we try to delete it, it doesn't actually throw an error or alert that the user doesn't exist. But I managed it through Python. Below is an example of Insert

def list_user_id(self):
query = "select user_id from user"
cur = self.con.cursor()
cur.execute(query)
record = [item[0] for item in cur.fetchall()]
return record

choice=int(input("enter your choice of 1 2 3 4 or 5 from above menu "))
if choice == 1:
user_list = helper.list_user_id()
user_id=int(input("Enter the user_id "))
if user_id not in user_list:
name=input("Enter the name ").capitalize()
phone=input("Enter the phone ").capitalize()
helper.insert_user(user_id,name,phone)
else:
print("user {} already in database, please use update instead".format(user_id))

Ответить
Yashas More
Yashas More - 02.01.2022 21:00

Sir the phone number column is giving error when i pass 10 digits why?

Ответить
Akash Dhakad
Akash Dhakad - 29.12.2021 12:02

❤️

Ответить
channu angadi
channu angadi - 19.12.2021 16:34

Sir when Deleting the item .even after the item not in the table it showing deleted ..........

Ответить
Srikanth Sidd's illegitimate father
Srikanth Sidd's illegitimate father - 04.12.2021 19:18

Bro this was good, but you could have wrapped everything in 25 min, you were telling lot of obvious things which were not necessary to be explicitly explained.

Ответить
Utkarsh Jain
Utkarsh Jain - 03.12.2021 23:30

Thanks sir for this video, if possible please give this code or anyone...

Ответить
manisha das
manisha das - 25.11.2021 10:39

Sir you explaination is very crystal clear thanks for this awesome video

Ответить
Rahulkumar Varma
Rahulkumar Varma - 05.11.2021 08:29

where can i gate this code

Ответить
Anurag Edlabadkar
Anurag Edlabadkar - 18.10.2021 16:33

Durgesh, this is very informative and interesting video. I found this video very interested and helpful. Thank you very much and keep it up.

Ответить
Priyank Patel
Priyank Patel - 17.10.2021 20:31

AMAzing Work It helped me for my CBSE project

Ответить
shinigami ryuk
shinigami ryuk - 03.10.2021 05:13

can I link html, css, mysql using python but without using any framework like django or any other

Ответить
Swathi Venkatesh
Swathi Venkatesh - 29.09.2021 01:20

Very good tutorials!

Ответить
Md. Razu Ahmed
Md. Razu Ahmed - 24.09.2021 21:23

def fetch_all(self,userID):
query = "select * from user_table where userID='{}'".format(userID)
cur = self.con.cursor()
cur.execute(query)
for row in cur:
print("User id: ",row[0])
print("User Name: ",row[1])
print("User Phone: ",row[2])
print()
print()
helper.fetch_all(101)

sir i would like to show information id ''101''

Ответить