What is PyMySQL and how does it differ from MySQLdb? Can it affect Django deployment?

PyMySQL and MySQLdb provide the same functionality – they are both database connectors. The difference is in the implementation where MySQLdb is a C extension and PyMySQL is pure Python. There are a few reasons to try PyMySQL: it might be easier to get running on some systems it works with PyPy it can be … Read more

Dynamic SQL Queries with Python and mySQL

Databases have different notations for “quoting” identifiers (table and column names etc) and values (data). MySQL uses backticks to quote identifiers. For values, it’s best to use the parameter substitution mechanism provided by the connector package: it’s more likely to handle tricky cases like embedded quotes correctly, and will reduce the risk of SQL injection. … Read more

Can’t install mysql-python (newer versions) in Windows

I solved it myself. I use the wheel installer from http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python. There are two wheel packages there. The amd64 one refuses to install on my platform (Windows) but the other one works just fine. I mean the file with this name: MySQL_python-1.2.5-cp27-none-win32.whl Then install it by running this below command in the same folder with … Read more

Why MYSQL IN keyword not considering NULL values

This : Error not in (‘Timeout’,’Connection Error’); is semantically equivalent to: Error <> ‘TimeOut’ AND Error <> ‘Connection Error’ Rules about null comparison applies to IN too. So if the value of Error is NULL, the database can’t make the expression true. To fix, you could do this: COALESCE(Error,”) not in (‘Timeout’,’Connection Error’); Or better … Read more

How can I use executemany to insert into MySQL a list of dictionaries in Python

itemBank = [] for row in rows: itemBank.append(( tempRow2[‘Item_Name’], tempRow1[‘Item_Price’], tempRow3[‘Item_In_Stock’], tempRow4[‘Item_Max’], getTimeExtra )) #append data q = “”” insert ignore into TABLE1 ( Item_Name, Item_Price, Item_In_Stock, Item_Max, Observation_Date ) values (%s,%s,%s,%s,%s) “”” try: x.executemany(q, itemBank) conn.commit() except: conn.rollback() Hope it will help you