Ben Chuanlong Du's Blog

It is never too late to learn.

Connect to MySQL Using PyMySQL

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

sudo pip3 install PyMySQL

Tricks

  1. Connection in PyMySQL is not autocommit by default. You must commit to save your changes.

    # suppose conn is the connection object
    conn.commit()
    
  2. parameterized sql: %s …