Python 3.7, Failed building wheel for MySql-Python
You need to install the following dependencies before installing mysqlclient for python 3.7 in your system. sudo apt-get install python3.7-dev default-libmysqlclient-dev I hope this will help you.
You need to install the following dependencies before installing mysqlclient for python 3.7 in your system. sudo apt-get install python3.7-dev default-libmysqlclient-dev I hope this will help you.
You’ll need to open multiple connections. Mysqldb is threadsafe, so each connection will be able to access their respective cursors, queries and result sets without having an effect on the other connections but each thread or process will need its own connection.
As the whole query needs to be in a string format while execution of query so %s should be used… After query is executed integer value is retained. So your line should be. .execute(“INSERT INTO table VALUES(%s,%s)”, (int(id), string)) Explanation is here
You should install MySQL through Homebrew first, to get python-mysql work properly on OS X. pip uninstall MySQL-python brew install mysql pip install MySQL-python
For Centos 7.0 install the following: yum install mariadb-devel For Fedora 23+: dnf install mariadb-devel
According to this article it is available by passing in ‘dictionary=True’ to the cursor constructor: http://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursordict.html so I tried: cnx = mysql.connector.connect(database=”bananas”) cursor = cnx.cursor(dictionary=True) and got: TypeError: cursor() got an unexpected keyword argument ‘dictionary’ and I tried: cnx = mysql.connector.connect(database=”bananas”) cursor = cnx.cursor(named_tuple=True) and got: TypeError: cursor() got an unexpected keyword argument ‘named_tuple’ and … Read more
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
To be a bit more complete: import MySQLdb connection = MySQLdb.connect( host=”localhost”, user=”myself”, passwd = ‘mysecret’) # create the connection cursor = connection.cursor() # get the cursor cursor.execute(“USE mydatabase”) # select the database cursor.execute(“SHOW TABLES”) # execute ‘SHOW TABLES’ (but data is not returned) now there are two options: tables = cursor.fetchall() # return data … Read more
I would create a stored procedure: DROP PROCEDURE IF EXISTS CopyTable; DELIMITER $$ CREATE PROCEDURE CopyTable(IN _mytable VARCHAR(64), _table_name VARCHAR(64)) BEGIN SET FOREIGN_KEY_CHECKS=0; SET @stmt = CONCAT(‘DROP TABLE IF EXISTS ‘,_table_name); PREPARE stmt1 FROM @stmt; EXECUTE stmt1; SET FOREIGN_KEY_CHECKS=1; SET @stmt = CONCAT(‘CREATE TABLE ‘,_table_name,’ as select * from ‘, _mytable); PREPARE stmt1 FROM @stmt; … Read more
You need to have installed the development libraries of OpenSSL. It can be a libssl-dev, libssl-devel if your distribution provides separated packages for the dev libraries. Or install the complete openssl package if they don’t. (venv)➜ src pip install mysql-python==1.2.5 Downloading/unpacking mysql-python==1.2.5 Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded Running setup.py (path:/home/braiam/src/venv/build/mysql-python/setup.py) egg_info for package mysql-python Installing … Read more