From 4e83b16542f70adf5e05d794dbc1dd80f120dc1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 3 Jul 2019 03:41:16 +0200 Subject: [PATCH] SQLite --- README.md | 5 ++++- index.html | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9eb970c..74fb742 100644 --- a/README.md +++ b/README.md @@ -1536,12 +1536,15 @@ db.executemany('', ) # Runs execute() many times. * **Passed values can be of type str, int, float, bytes, None, bool, datetime.date or datetime.datetme.** ### MySQL +**Has a very similar interface, with differences listed below.** ```python # $ pip3 install mysql-connector from mysql import connector db = connector.connect(host=, user=, password=, database=) cursor = db.cursor() -cursor.execute('') +cursor.execute('') # Connector doesn't have execute method. +cursor.execute('', ) # Replaces '%s's in query with values. +cursor.execute('', ) # Replaces '%()s's with values. ``` diff --git a/index.html b/index.html index e65e473..3d0b3b6 100644 --- a/index.html +++ b/index.html @@ -1355,11 +1355,14 @@ db.executemany('<query>', <coll_of_abo
  • Passed values can be of type str, int, float, bytes, None, bool, datetime.date or datetime.datetme.
  • MySQL

    +

    Has a very similar interface, with differences listed below.

    # $ pip3 install mysql-connector
     from mysql import connector
     db = connector.connect(host=<str>, user=<str>, password=<str>, database=<str>)
     cursor = db.cursor()
    -cursor.execute('<query>')
    +cursor.execute('<query>')                     # Connector doesn't have execute method.
    +cursor.execute('<query>', <list/tuple>)       # Replaces '%s's in query with values.
    +cursor.execute('<query>', <dict/namedtuple>)  # Replaces '%(<key>)s's with values.
     

    #Bytes

    Bytes object is an immutable sequence of single bytes. Mutable version is called 'bytearray'.