limit का use Database Table से limited records select करने के लिए किया जाता है।

# import connector class from mysql module.
import mysql.connector as myconn mydb = myconn.connect( host = 'localhost', user = 'root', password = '', database = 'python_db' ) db_cursor = mydb.cursor() # select only 2 records. query = "SELECT * FROM users LIMIT 2" db_cursor.execute(query) rows = db_cursor.fetchall() for row in rows : print(row)

Limit से आप सिर्फ records को select करने के limited records को update / delete भी कर सकते हैं।
For Example -

#delete 5 records.
query = "DELETE FROM users WHERE last_name=%s LIMIT 5" value = ('Singh', ) db_cursor.execute(query, value) #update only 3 records. query = "UPDATE users SET email = %s WHERE id=%s LIMIT 3" set_value = ('', 1) db_cursor.execute(query, set_value)

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook