mysql-python

Cannot Import Python MySQL module when running a script using crontab

允我心安 提交于 2019-11-29 08:30:18
问题 I am using crontab to run a python script that requires the module MySQLdb. When I run this script from the command line everything works fine. However, trying to run it using crontab elicits this error. Traceback (most recent call last): File "clickout.py", line 3, in <module> import MySQLdb ImportError: No module named MySQLdb I did a google search and added this to the top of my script #!/usr/bin/python . However, this didn't do anything and I am still getting the same error. What am I

django.db.utils.operationalError: (2059,“Authentication Plugin 'caching_sha2_password'”)

巧了我就是萌 提交于 2019-11-29 08:03:53
I am trying to connect my django project 'mysite' to mysql. I made a user in mysql and granted it all privileges to access the project. These are the changes I made to settings.py : DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mysitedb', 'USER': 'username', 'PASSWORD': 'password', 'HOST': 'localhost', 'PORT': '', } } Now when I try to migrate the database using python3 manage.py makemigrations , I get the following error: django.db.utils.OperationalError: (2059, "Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/mysql/plugin/caching_sha2

Failed building wheel for mysql-python

你说的曾经没有我的故事 提交于 2019-11-29 07:48:19
I want to run a Django application in PyCharm which works on MySQL DB. I am unable to connect my program to the database. When I am trying to install MySQLclient or MySQL-python I am getting the error: Failed building wheel for MySQLclient Please help me out in connecting my Django program with MySQL database. Gaurav Vasudev Edit Please try installing the .whl file from http://www.lfd.uci.edu/~gohlke/pythonlibs/ . This works every time. Just type pip install MySQL_python‑1.2.5‑cp27‑none‑win32.whl in the terminal. Original Answer I had the same issue. You might find these steps helpful. Make

How to install python2.6-devel package under CentOs 5

两盒软妹~` 提交于 2019-11-29 07:06:09
I need to install mysql-python under python2.6. mysql-python package needs python2.6-devel package that depends on the libpython2.6.so.1.0(64bit) I found on the net some python2.6-devel packages, but can't find libpython2.6 Server architecture is x86_64. Maybe someone have this lib, or know where i can find it. Thanks for help) I have the same issue and this wonderful link solved it for me... http://blog.milford.io/2010/08/new-method-for-installing-python-2-6-4-with-mysql-python-on-centos-5-5/ I followed some of the steps out of order because I was a little antsy and got some interesting error

ssh first with mysqldb in python

倾然丶 夕夏残阳落幕 提交于 2019-11-29 04:50:22
I'm trying to connect to a MySQL database on a remote server using MySQLdb in python. The problem is that first I need to SSH into the host, and then from there, I need to connect to the MySQL server. The problem I'm having, though, is that MySQLdb does not seem to have a way of establishing an SSH connection before connecting to the SQL server. I've checked the documentation but have not had any luck. This is how I'm connecting: conn = MySQLdb.connect(host = 'mysqlhost.domain.com:3306', user = 'user', passwd = 'password', db = 'dbname') But what I really need is something like this: conn =

How do I check if an insert was successful with MySQLdb in Python?

匆匆过客 提交于 2019-11-29 04:05:39
I have this code: cursor = conn.cursor() cursor.execute(("insert into new_files (videos_id, filename, " "is_processing) values (%s,%s,1)"), (id, filename)) logging.warn("%d", cursor.rowcount) if (cursor.rowcount == 1): logging.info("inserted values %d, %s", id, filename) else: logging.warn("failed to insert values %d, %s", id, filename) cursor.close() Fun as it is, cursor.rowcount is always one, even though i updated my database to make the videos_id a unique key. That is, the insert fails because in my tests the same videos_id is going to appear (and when I check the database, nothing was

questions about pandas.to_sql

回眸只為那壹抹淺笑 提交于 2019-11-29 02:53:42
问题 I have a question about how to save a dataframe to my local mysql. import MySQLdb import pandas as pd conn=MySQLdb.connect(host="localhost",user='root',passwd="matt123",db="ada") df=pd.DataFrame(['A','B'],columns=['new_tablecol']) df.to_sql(name='new_table',con=conn,if_exists='append') after typing this code , it says pandas.io.sql.DatabaseError: Execution failed on sql 'SELECT name FROM sqlite_master WHERE type='table' AND name=?;': not all arguments converted during string formatting I am

how to insert to a mysql table using mysaldb, where the table name is in a python variable?

▼魔方 西西 提交于 2019-11-29 02:37:53
I'm using python-mysql db api to insert some values to a table where the table name is in a python variable. So I wrote the below code DB_CURSOR.execute("""INSERT INTO %s (name,created_by,state,description,docs,admin_email,date_created) VALUES(%s,%s,%s,%s,%s,%s,%s)""", (hosts_table, hostname, created_by, state, description, docroot, admin_email, date_created)) As you see the table name is in the hosts_table variable. The problem is mysqldb quotes the table name and i get a mysql error. It works fine when I literally use the table name. How can I get around this? DB_CURSOR.execute("""INSERT

MySQLdb returns not all arguments converted with “on duplicate key update”

谁说胖子不能爱 提交于 2019-11-29 02:31:41
With MySQLdb package in python, I want to insert records with checking some unique keys. The method I used is executemany. The arguments are sql sentence and a tuple. But when I executed it, it raised an error which said "not all argument converted". The codes are as following: dData = [[u'Daniel', u'00-50-56-C0-00-12', u'Daniel']] sql = "INSERT INTO app_network_white_black_list (biz_id, shop_id, type, mac_phone, remarks, create_time) " \ "VALUES ({bsid}, {shop_id}, {type}, %s, %s, NOW()) " \ "ON DUPLICATE KEY UPDATE type={type}, remarks=%s, create_time=NOW()".format(bsid=bsid, shop_id=shop_id

Installing MySQLdb on Mac OS X

最后都变了- 提交于 2019-11-28 23:52:09
I've spent several hours trying to install MySQLdb (the Python library) on Mac OS X Snow Leopard. I'm using these instructions from SO. I keep getting an error, so I've tried using MacPorts (as one of the answers to that question advises), but I continue to get the same error. Can anybody help? import MySQLdb Traceback (most recent call last): File "<stdin>", line 1, in <module> File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in <module> File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module> File "build/bdist.macosx-10.6-universal/egg/_mysql.py",