MySQLdb - weird formatting inconsistency

A

Anthra Norell

Hi all,

Can anyone explain this? Three commands with three different cutoff
dates (12/30, 12/31 and 1/1) produce a formatting inconsistency. Examine
the third field. The first and last run represents it correctly. The
second run strips it. The field happens to be a record ID and getting it
stripped in an unpredictable manner obviously makes it useless as an ID.
and "1987-12-30";')
761L
(9737, '', ' 2278', datetime.date(1987, 1, 1), 5000.0, 'IIfVNg',
'IIfAC', '', '', 'Schweigegeld')
(9738, '', ' 2279', datetime.date(1987, 1, 5), 28.5, 'IIfVZc', 'IIfAC',
'', '', '1 Schachtel 9mm')
(9739, '', ' 2280', datetime.date(1987, 1, 5), 73.85, 'IIfVZm', 'IIfAC',
'', '', 'Gladiolen')
.. . .
and "1987-12-31";')
792L
(9737, '', '2278', datetime.date(1987, 1, 1), 5000.0, 'IIfVNg', 'IIfAC',
'', '', 'Schweigegeld')
(9738, '', '2279', datetime.date(1987, 1, 5), 28.5, 'IIfVZc', 'IIfAC',
'', '', '1 Schachtel 9mm')
(9739, '', '2280', datetime.date(1987, 1, 5), 73.85, 'IIfVZm', 'IIfAC',
'', '', 'Gladiolen')
.. . .
and "1988-01-01";')
796L
(9737, '', ' 2278', datetime.date(1987, 1, 1), 5000.0, 'IIfVNg',
'IIfAC', '', '', 'Schweigegeld')
(9738, '', ' 2279', datetime.date(1987, 1, 5), 28.5, 'IIfVZc', 'IIfAC',
'', '', '1 Schachtel 9mm')
(9739, '', ' 2280', datetime.date(1987, 1, 5), 73.85, 'IIfVZm', 'IIfAC',
'', '', 'Gladiolen')
.. . .
Curiously, the second command with a limit works correctly, including
'limit 792' which is equal to the number of selected records.
and "1987-12-31" limit 792;')
792L
(9737, '', ' 2278', datetime.date(1987, 1, 1), 5000.0, 'IIfVNg',
'IIfAC', '', '', 'Schweigegeld')
(9738, '', ' 2279', datetime.date(1987, 1, 5), 28.5, 'IIfVZc', 'IIfAC',
'', '', '1 Schachtel 9mm')
(9739, '', ' 2280', datetime.date(1987, 1, 5), 73.85, 'IIfVZm', 'IIfAC',
'', '', 'Gladiolen')
.. . .

A variation of the problematic command showing only the IDs between
start and end marks works okay too:
between "1987-01-01" and "1987-12-31";')
792L
('| 2278|',)
('| 2279|',)
('| 2280|',)
.. . .


After playing around with various date combinations the impression
emerges that only 1/1/87-12/31/87 misbehaves. All other combinations I
tried did okay.
All runs were done in an IDLE window, one after the other, with the
same cursor object.
Ubuntu: 9.10. Python: 2.6. MySQL: 5.1.45.
The record ID is declared as char (8) and a unique key. I don't think
this matters, though, since run from the mysql command line everything
works fine. It does look like a MySQLdb problem and a pretty weird one
at that. Suggestions?

Thanks

Frederic
 
J

John Nagle

Anthra said:
Hi all,

Can anyone explain this? Three commands with three different cutoff
dates (12/30, 12/31 and 1/1) produce a formatting inconsistency. Examine
the third field. The first and last run represents it correctly. The
second run strips it. The field happens to be a record ID and getting it
stripped in an unpredictable manner obviously makes it useless as an ID.

and "1987-12-30";')
761L

(9737, '', ' 2278', datetime.date(1987, 1, 1), 5000.0, 'IIfVNg', 'IIfAC', '', '', 'Schweigegeld')
(9738, '', ' 2279', datetime.date(1987, 1, 5), 28.5, 'IIfVZc', 'IIfAC', '', '', '1 Schachtel 9mm')
(9739, '', ' 2280', datetime.date(1987, 1, 5), 73.85, 'IIfVZm', 'IIfAC', '', '', 'Gladiolen')
. . .

and "1987-12-31";')
792L
(9737, '', '2278', datetime.date(1987, 1, 1), 5000.0, 'IIfVNg', 'IIfAC', '', '', 'Schweigegeld')
> (9738, '', '2279', datetime.date(1987, 1, 5), 28.5, 'IIfVZc', 'IIfAC', '', '', '1 Schachtel 9mm')
(9739, '', '2280', datetime.date(1987, 1, 5), 73.85, 'IIfVZm', 'IIfAC', '', '', 'Gladiolen')
. . .

Those are the first and second runs. Where, exactly, do they differ?

John Nagle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,734
Latest member
manin

Latest Threads

Top