I'm using .executesql.  I added a line to sql.py for debugging
purposes.  It returns the second column of the first row of results (a
SUM of a SQL Server money column):

diff --git a/gluon/sql.py b/gluon/sql.py
--- a/gluon/sql.py
+++ b/gluon/sql.py
@@ -1389,6 +1389,7 @@
             data = self._cursor.fetchall()
             # convert the list for each row into a dictionary so it's
             # easier to work with. row['field_name'] rather than
row[0]
+            raise RuntimeError(type(data[0][1]))
             return [dict(zip(fields,row)) for row in data]
         # see if any results returned from database
         try:


When I run on Windows, I get:

RuntimeError: <class 'decimal.Decimal'>


When I run on Linux, I get:

RuntimeError: <type 'float'>




On Jul 30, 10:32 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Are they both connecting to the same database?
> Can you provide an example of how you insert and how you extract data?
>
> This is to understand the issue better. In fact
> gluon/sql.py contains the following code:
>
> ...
> elif field.type[:7] == 'decimal' and value != None:
>                     decimals = [int(x) for x in
> field.type[8:-1].split(',')][-1]
>                     if field._db._dbname == 'sqlite':
>                         value = ('%.'+str(decimals)+'f') % value
>                     if not isinstance(value,decimal.Decimal):
>                         value = decimal.Decimal(str(value))
> ...
>
> so technically even if the database where to return float (wrong),
> web2py should still return decimal. Is this the case for you?
>
> On Jul 30, 8:35 am, mwolfe02 <michael.joseph.wo...@gmail.com> wrote:
>
>
>
> > For background, refer to related questions on 
> > SO:http://stackoverflow.com/questions/3364699/http://stackoverflow.com/q...
>
> > I'm developing my app on Windows, but will be deploying it on a Linux
> > server.  The following lines are from the top of my db.py:
>
> > if os.name=='posix':  #Ubuntu
> >     db = DAL('mssql://user:p...@10.0.8.30/TaxDB?DRIVER={FreeTDS}',
> > migrate=False)
> > elif os.name=='nt':   #Windows
> >     db = DAL('mssql://u...@127.0.0.1/TaxDB_Dev?
> > Trusted_Connection=Yes', migrate=False)
>
> > The problem I am running into is that on Windows, my MS SQL money
> > fields are returned as Python Decimals.  However, on Linux, those same
> > fields are returned as floats.  I think the issue is with FreeTDS.
> > The above lines are the _only_ lines that are different between my
> > production and development versions.  Obviously, the environments
> > themselves are vastly different.
>
> > Is there an alternative to FreeTDS to connect to SQL Server from
> > Linux?  Do I need to provide some additional info in my connection
> > string?  Am I just stuck because I'm accessing SQL Server from Linux?
>
> > Thanks in advance for any insight.

Reply via email to