<spanclass="hljs-keyword">from</span> mysql <spanclass="hljs-keyword">import</span> connector
db = connector.connect(host=<str>, user=<str>, password=<str>, database=<str>)
cursor = db.cursor()
cursor.execute(<spanclass="hljs-string">'<query>'</span>) <spanclass="hljs-comment"># Connector doesn't have execute method.</span>
cursor.execute(<spanclass="hljs-string">'<query>'</span>) <spanclass="hljs-comment"># Only cursor has execute method.</span>
cursor.execute(<spanclass="hljs-string">'<query>'</span>, <list/tuple>) <spanclass="hljs-comment"># Replaces '%s's in query with values.</span>
cursor.execute(<spanclass="hljs-string">'<query>'</span>, <dict/namedtuple>) <spanclass="hljs-comment"># Replaces '%(<key>)s's with values.</span>