I've not been able to get count aggregates to work with the 1.2.2 or 1.2.2c1 versions connecting to a MySQL version: 4.1.12.
The code is:
long_string = "SELECT sleuth_Testcase.tcName, \
sleuth_Testcase.tcPass, \
COUNT (sleuth_Testcase.tcPass) \
FROM sleuth_Testcase \
GROUP BY sleuth_Testcase.tcPass"
cursor.execute (long_string)
The result is:
Traceback (most recent call last):
File "C:\Documents and Settings\schnellman\D\Python\Query4F.py", line 30, in <module>
cursor.execute (long_string)
File "C:\Python25\lib\site-packages\MySQLdb\cursors.py", line 166, in execute
self.errorhandler(self, exc, value)
File "C:\Python25\lib\site-packages\MySQLdb\connections.py", line 35, in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (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 '(sleuth_Testcase.tcPass) FROM sleuth_Testcase GROUP BY sleuth_Testcase.tcPass' at line 1")
However, if the select is sent directly to MySQL with the Python syntax removed, it works. I ran more than 10 different single and multi-table queries and all failed.
Other queries, using other aggregate functions like SUM and AVG work fine, both directly to the MySQL server and through Python.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is a compatibility issue. I'm a long-term SQL 2000 and SQL 2005 user and add a spcae between count and (). I found that by setting the mode, the errors disappeared.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've not been able to get count aggregates to work with the 1.2.2 or 1.2.2c1 versions connecting to a MySQL version: 4.1.12.
The code is:
long_string = "SELECT sleuth_Testcase.tcName, \ sleuth_Testcase.tcPass, \ COUNT (sleuth_Testcase.tcPass) \ FROM sleuth_Testcase \ GROUP BY sleuth_Testcase.tcPass"
cursor.execute (long_string)
The result is:
Traceback (most recent call last):
File "C:\Documents and Settings\schnellman\D\Python\Query4F.py", line 30, in <module>
cursor.execute (long_string)
File "C:\Python25\lib\site-packages\MySQLdb\cursors.py", line 166, in execute
self.errorhandler(self, exc, value)
File "C:\Python25\lib\site-packages\MySQLdb\connections.py", line 35, in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (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 '(sleuth_Testcase.tcPass) FROM sleuth_Testcase GROUP BY sleuth_Testcase.tcPass' at line 1")
However, if the select is sent directly to MySQL with the Python syntax removed, it works. I ran more than 10 different single and multi-table queries and all failed.
Other queries, using other aggregate functions like SUM and AVG work fine, both directly to the MySQL server and through Python.
If it's an SQL syntax error, it cannot be a problem with MySQLdb.
Try removing the space between "COUNT" and "(".
This is a compatibility issue. I'm a long-term SQL 2000 and SQL 2005 user and add a spcae between count and (). I found that by setting the mode, the errors disappeared.