Skip to content

Language

Sign in

Learn › Class 12 › Computer Science / Informatics Practices › Python and MySQL connectivity

Python and MySQL connectivity

Remember

  • connect() → cursor() → execute() → fetchone()/fetchmany()/fetchall() → close().
  • commit() saves INSERT, UPDATE and DELETE.
  • Use %s placeholders with a tuple of values to prevent SQL injection.

Quick self-check

  1. What does cursor.rowcount tell you after an UPDATE?

    Check

    How many rows the UPDATE changed.

  2. Why close the connection?

    Check

    To free the server's resources and end the session cleanly.

Reviewed by EduFlint team on 1 Dec 2026 · version 1

Written by us for this site. Independent; not affiliated with NCERT or CBSE.

Report a mistake

Looking for another topic?