Re: MySQL double
Sebastien Bigaret <[email protected]> 03 Feb 2004 14:42:04 +0100
| Newsgroups | gmane.comp.python.modeling |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Ralf Sigmund <[email protected]> wrote:
> Greetings!
>
> I have recently started to use modeling for my bioinformatics work.
> I like it a lot but now i ran into a small problem.
> I often need to store small numbers like 1.24e-127
> The MySQL datataype double stores theese correctly while float reduces them to
> 0.0 which is a catastrophe for me.
> So I tried to specify double as external datatayp, but the mdl-validate fails
> telling me that double is not supported.
> Is it possible to expand the mysql adapter to support double?
Absolutely :) Apply the attached patch and you should be able to use
MySQL's DOUBLE. Use precision=0, scale=0 for the default DOUBLE, or
precision=M, scale=D for DOUBLE(M,D). If you can report that this
works as expected, this will be in the next release.
Hope this helps,
-- Sébastien.
Index: DatabaseAdaptors/MySQLAdaptorLayer/MySQLSQLExpression.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer/MySQLSQLExpression.py,v
retrieving revision 1.8
diff -u -r1.8 MySQLSQLExpression.py
--- DatabaseAdaptors/MySQLAdaptorLayer/MySQLSQLExpression.py 15 Dec 2003 15:05:00 -0000 1.8
+++ DatabaseAdaptors/MySQLAdaptorLayer/MySQLSQLExpression.py 3 Feb 2004 13:31:02 -0000
@@ -34,7 +34,8 @@
__version__='$Revision: 1.8 $'[11:-2]
from Modeling.DatabaseAdaptors.MySQLAdaptorLayer.mysql_utils import *
-from Modeling.SQLExpression import SQLExpression, DateType, CharacterType
+from Modeling.SQLExpression import SQLExpression
+from Modeling.SQLExpression import DateType, CharacterType, NumericType
from Modeling.logging import trace, db_trace
import string
@@ -117,7 +118,8 @@
values=SQLExpression.valueTypeForExternalTypeMapping.im_func(self)
del values['timestamp']
values.update({ 'datetime': DateType,
- 'text': CharacterType })
+ 'text': CharacterType,
+ 'double': NumericType })
return values
def prepareSelectCountExpressionWithAttributes(self,
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn