Комментарии:
I my internship project while insert query in mysql getting cursor not connected error repeatedly. Checked everything, but error not solved
ОтветитьCan this project be included in resume for placement
ОтветитьHi I am facing some problem in connection
ОтветитьWish these had English subtitles
Ответитьlike you make one table here if we want to make multiple table using this approach what should we do?
ОтветитьSource code bhi de deta BKL
ОтветитьGreat teaching ❤️
Can I please get this project complete code??
To use the class, first, you will have to create an instance after that I will work properly
ОтветитьNice Explanation. This helped me.
Ответить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
Ответить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()
Your teaching technique is legendary sir
ОтветитьWonderful video. Too much informative.
Ответитьcan i get the code of this video
Ответитьsir i request you , plzz make a search function Enter Id to search
Ответить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..
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
excellent
ОтветитьReally this video is very helpful for me. Thanks 👍
ОтветитьEk number sir!! Really wanted this!
Ответить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])
Where to get source code ?
ОтветитьGetting error while creating table.
raise AttributeError(item)
AttributeError: con
Help me with this
Thank you so much for a detailed tutorial. I was able to create a great program by using your guidelines. ☺️
Ответитьbro am getting an error in cmd
Ответитьdone it bit different..........change the menu text with red and all the code is made with function
Ответить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")
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()
done 👍👍👍👍👍👍👍👍
Ответить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
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
That is amazing for me. Thankyou sir
Ответить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))
Sir the phone number column is giving error when i pass 10 digits why?
Ответить❤️
ОтветитьSir when Deleting the item .even after the item not in the table it showing deleted ..........
Ответить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.
ОтветитьThanks sir for this video, if possible please give this code or anyone...
ОтветитьSir you explaination is very crystal clear thanks for this awesome video
Ответитьwhere can i gate this code
ОтветитьDurgesh, this is very informative and interesting video. I found this video very interested and helpful. Thank you very much and keep it up.
ОтветитьAMAzing Work It helped me for my CBSE project
Ответитьcan I link html, css, mysql using python but without using any framework like django or any other
ОтветитьVery good tutorials!
Ответить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''