Tuesday , September 17 2024

Machine Learning

Python MySQL Drop Table

Python MySQL Drop Table

9 Python MySQL Drop Table Python MySQL Drop Database¶ Query: drop database database_name In [ ]: import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", passwd="" ) mycursor = mydb.cursor() mycursor.execute("drop database itronix") Python MySQL Drop Table¶ Query: drop table table_name In [6]: import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", passwd="", database="itronix" ) mycursor = …

Read More »

Python MySQL Update Table

Python MySQL Update Table

10 Python MySQL Update Table Python MySQL Update Table¶You can update existing records in a table by using the “UPDATE” statement: In [22]: import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", passwd="", database="itronix" ) mycursor = mydb.cursor() sql = "UPDATE customers SET address = 'Detroit' WHERE address = 'Ludhiana'" mycursor.execute(sql) mydb.commit() print(mycursor.rowcount, …

Read More »

Python MySQL Limit

Python MySQL Limit

11 Python MySQL Limit Python MySQL Limit¶ You can limit the number of records returned from the query, by using the “LIMIT” statement: In [23]: import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", passwd="", database="itronix" ) mycursor = mydb.cursor() mycursor.execute("SELECT * FROM customers LIMIT 5") myresult = mycursor.fetchall() for x in myresult: …

Read More »

Python MySQL Join

Python MySQL Join

12 Python MySQL Join Python MySQL Join¶ Join Two or More Tables You can combine rows from two or more tables, based on a related column between them, by using a JOIN statement. Consider you have a “customers” table and a “product” table: Create Table Name Product¶ In [29]: import mysql.connector …

Read More »

Python MySQL Database

Python MySQL Database

Python MySQL Database Python MySQL Database¶Python can be used in database applications. One of the most popular databases is MySQL. Python needs a MySQL driver to access the MySQL database. pip install mysql-connector-python MySQL Database¶To be able to experiment with the code examples in this tutorial, you should have MySQL …

Read More »

Face Detection with Name in Python using OpenCV

15 Face Detection with Name Face Detection with Name in Python using OpenCV¶ python -m pip install opencv-contrib-python pip install pillow Step 1: Collect 20 Samples of a Face¶ In [11]: import cv2 cam = cv2.VideoCapture(0) detector=cv2.CascadeClassifier('haarcascade_frontalface_default.xml') Id=input('Enter Your Id:') sampleNum=0 while(True): ret, img = cam.read() gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) faces …

Read More »

Face Detection From an Image in Python using OpenCV

13 Face Detection from Image Face Detection From an Image in Python using OpenCV¶ https://github.com/opencv/opencv/tree/master/data/haarcascades You need to download the trained classifier XML file (haarcascade_frontalface_default.xml), which is available in OpenCv’s GitHub repository. Save it to your working location. The detection works only on grayscale images. So it is important to …

Read More »

Record Video From a Webcam using OpenCV

12 Record Video using OpenCV Record Video From a Webcam using OpenCV¶ cv2.VideoWriter( filename, fourcc, fps, frameSize ) The parameters are : filename: Specifies the name of the output video file. fourcc: (for recording) Defining the codec fps: Defined frame rate of the output video stream frameSize: Size of the …

Read More »

Access Camera Using OpenCV with Python

11 Open Webcam Access Camera Using OpenCV with Python¶ first, we Import libraries OpenCV. Then we use VideoCapture(0) function to capture the feed of the webcam, here 0 indicates the default value of webcam. If you have secondary webcam use 1 instead of 0 Now read the frame of the …

Read More »