king di ~> python test_sql_warns.py
(1, 2, 0, 'final', 1)
num warnings: 1
king di ~>
prints nothing. I will install and try 1.2.1c3 later, but I've looked in the ChangeLog for and I don't see any mention of this problem. Anyone have any suggestions?
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is on Gentoo:
/newbig/MySQL-python-1.2.1c3> uname -a
Linux blackie 2.6.14-gentoo-r2 #1 PREEMPT Sun Nov 20 15:46:06 MST 2005 i686 AMD Athlon(tm) XP 1800+ AuthenticAMD GNU/Linux
/newbig/MySQL-python-1.2.1c3> python -V
Python 2.4.2
/newbig/MySQL-python-1.2.1c3> mysql --version
mysql Ver 14.12 Distrib 5.0.18, for pc-linux-gnu (i686) using readline 5.0
/newbig/MySQL-python-1.2.1c3> mysql -u mysql test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11 to server version: 4.1.14-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> desc foo;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| c | char(1) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.11 sec)
Hi,
I'm using MySQL 5.0.15
Your MySQL connection id is 2267 to server version: 5.0.15-standard-log
and I have a table:
mysql> create table foo ( c char(5) );
Query OK, 0 rows affected (0.02 sec)
mysql> insert into foo (c) values ("123456");
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+----------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------+
| Warning | 1265 | Data truncated for column 'c' at row 1 |
+---------+------+----------------------------------------+
1 row in set (0.00 sec)
So, MySQL generates the warning, for sure; however, this code:
from MySQLdb import *
import warnings
print version_info
warnings.filterwarnings('error', '.*', Warning, 'MySQLdb')
Make /all/ warnings errors, for good measure
warnings.filterwarnings('error')
conn = connect(<secret parms>)
cursor = conn.cursor()
cursor.execute("insert into foo(c) values('123456')")
print "num warnings:", cursor._warnings
king di ~> python test_sql_warns.py
(1, 2, 0, 'final', 1)
num warnings: 1
king di ~>
prints nothing. I will install and try 1.2.1c3 later, but I've looked in the ChangeLog for and I don't see any mention of this problem. Anyone have any suggestions?
Thanks.
This is on Gentoo:
/newbig/MySQL-python-1.2.1c3> uname -a
Linux blackie 2.6.14-gentoo-r2 #1 PREEMPT Sun Nov 20 15:46:06 MST 2005 i686 AMD Athlon(tm) XP 1800+ AuthenticAMD GNU/Linux
/newbig/MySQL-python-1.2.1c3> python -V
Python 2.4.2
/newbig/MySQL-python-1.2.1c3> mysql --version
mysql Ver 14.12 Distrib 5.0.18, for pc-linux-gnu (i686) using readline 5.0
/newbig/MySQL-python-1.2.1c3> mysql -u mysql test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11 to server version: 4.1.14-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> desc foo;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| c | char(1) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.11 sec)
mysql> insert into foo(c) values("hola");
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+----------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------+
| Warning | 1265 | Data truncated for column 'c' at row 1 |
+---------+------+----------------------------------------+
1 row in set (0.01 sec)
test_warn.py
import MySQLdb
import warnings
print MySQLdb.version_info
warnings.filterwarnings('error')
conn = MySQLdb.connect(host='localhost', user='mysql', db='test')
cursor = conn.cursor()
cursor.execute("insert into foo(c) values('hi ho')")
..........
/newbig/MySQL-python-1.2.1c3> python test_warn.py
(1, 2, 1, 'gamma', 3)
/newbig/MySQL-python-1.2.1c3>
-no exception...
Am I doing something wrong, or does it just not work on 5.0.x versions, for high x?
Thanks for any help.
Doing the same thing from C, mysql_info() doesn't return warning text, either (mysql_warning_count() works, of course).