mysql-python

Testing AWS Elastic Beanstalk scaling

北慕城南 提交于 2019-12-06 13:21:28
I've set up a server in elastic beanstalk. When required, it is supposed to increase the number of instances from 1 to up to 4. I have a sneaking suspicion, however, that when it starts a new instance that instance won't be properly configured, because I was unable to install the mySQL module for Python without ssh'ing into the instance and setting it up manually, as per this question . So my first question is what is the best way to test that Elastic Beanstalk is scaling correctly? If new instances are started up, how can I be sure that I'm seeing one of the new ones rather than the original,

Use Python list in SQL query for column names

时光毁灭记忆、已成空白 提交于 2019-12-06 11:24:51
问题 I have a bunch of column names in a Python list. Now I need to use that list as the column names in a SELECT statement. How can I do that? pythonlist = ['one', 'two', 'three'] SELECT pythonlist FROM data; So far I have: sql = '''SELECT %s FROM data WHERE name = %s INTO OUTFILE filename''' cur.execute(sql,(pythonlist,name)) 回答1: You cannot pass list of columns to select as a parameter to cur.execute . It should be part of your SQL expression, something like: sql = "SELECT " + ",".join

Django + MySQL - Admin Site - Add User - OperationalError - SAVEPOINT does not exist

不羁的心 提交于 2019-12-06 06:12:59
We're trying to have a custom User model and behaviors, but then we noticed that even the default Django installation has issue when adding a new User via the Django Admin: The issue happens even in other Django versions (tried it in Django 1.8 , and w/ the latest one, Django 1.11.3 ). Surprisingly, the issue does not happen when using SQLite or PostgreSQL databases. Also, adding user via $./manage.py createuser and programmatically will work. Editing existing uses like the previously created admin superuser via terminal will also work. CRUD mechanisms for Group work as intended, hence only

MySQLdb.cursors.Cursor.execute returns different values in case of different cursors why?

送分小仙女□ 提交于 2019-12-06 05:06:25
See these two python code snippets, conn = MySQLdb.connect(c['host'], c['user'], c['password'], c['db']) cur = conn.cursor() cur.execute("select * from geo_weathers;) -> **1147L** and conn = MySQLdb.connect(c['host'], c['user'], c['password'], c['db'], cursorclass=MySQLdb.cursors.SSCursor) cur = conn.cursor() cur.execute("select * from geo_weathers") -> **18446744073709551615L** Why the returned number of rows are different in above two cases ? And just FYI there are 1147 rows in a table. SSCursor is used for saving result at servers side. Is it the reason ? What all rows are affected by this

MySQLdb and Python ImportError

守給你的承諾、 提交于 2019-12-06 03:40:06
问题 I cannot for the life of me figure this one out. I've been searching around the web all day and all the resources seem terribly out dated. From what I can tell getting MySQLdb and Python to play nice together is fairly difficult. I've gotten about as far as I can on this, and I'm not sure how to proceed going forward. First off, I am running Python 2.7 The error I get when I try and run "import MySQLdb" in the live interpreter is this: ImportError: this is MySQLdb version (1, 2, 2, 'final', 0

UPDATE or INSERT MySQL Python

若如初见. 提交于 2019-12-06 01:50:29
问题 I need to update a row if a record already exists or create a new one if it dosen't. I undersant ON DUPLICATE KEY will accomplish this using MYSQLdb, however I'm having trouble getting it working. My code is below cursor = database.cursor() cursor.execute("INSERT INTO userfan (user_id, number, round VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE user_id =%s, number=%s, round=%s", (user_id, number, round)) database.commit() primary key is user_id 回答1: A parenthesis was missiing. You can also use

1064, “You have an error in your SQL syntax;…” Python MySQL

假装没事ソ 提交于 2019-12-06 00:06:01
So I have been working on this since last Friday and cannot get around this error: 1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[u'161010-035670'] WHERE order_id=87' at line 1" or something along the same lines as this error. Basically my python will grab data from MySQL database, it creates a case in SalesForce using Simple-Salesforce and then queries that case it created correctly but I need it to write that case number back into the database in a column I created specifically for the ticket

No module named MySQLdb even if MySQL-python installed?

南笙酒味 提交于 2019-12-05 15:49:08
I have a CentOS box. (venv)[root@localhost]# yum install MySQL-python Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.maine.edu * epel: ftp.osuosl.org * extras: mirror.us.leaseweb.net * remi: rpms.famillecollet.com * updates: mirrors.centarra.com Setting up Install Process Package MySQL-python-1.2.3-0.3.c1.1.el6.x86_64 already installed and latest version Nothing to do ... (venv)[root@localhost]# python Python 2.7.6 (default, May 20 2014, 20:23:08) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright",

MySQL-python, error: command 'gcc-4.2' failed with exit status 1

♀尐吖头ヾ 提交于 2019-12-05 15:47:27
I've been looking around for a solution to this, and there seem to be a lot of different solutions, but none seem to be working. I'm using MySQL-Python to try to get MySQL set up with python. But, when I try to run sudo python setup.py build I get the following error: Password: running build running build_py copying MySQLdb/release.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb running build_ext building '_mysql' extension gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -g -O2 -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr

Can't import MySQLdb module in Python

孤街浪徒 提交于 2019-12-05 11:16:59
I'm trying to use MySQL in Python. I have installed the MySQL adapter (MySQL-python-1.2.4b4.win32-py2.7) for Python, but when I try to import the MySQLdb module (import MySQLdb) with command prompt I receive the following output: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 19, in <module> import _mysql ImportError: DLL load failed: %1 is not a valid Win32 application. Would anybody know, what could be wrong? You need to have a 32bit version of Python to use this adapter. Which version are you actually