I went and double checked on a local install of web2py and I am getting the 
same result. I also logged into the web server and ran a python script to 
test as the web server user and I do get the expected results from the 
database.

I am still confused at what could be causing this. 



On Wednesday, August 5, 2015 at 9:36:11 PM UTC-4, David wrote:
>
> Running it from the web2py shell by importing the pymssql is returning no 
> results. I am not getting an error I just get: 
>
> In [10] : rows = cursor.execute("SELECT * FROM PERSON WHERE 
> PERSON.LAST_NAME = 'Palmer'")
>
> In [11] : print len(rows)
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/contrib/shell.py", line 234, in run
>     exec compiled in statement_module.__dict__
>   File "<string>", line 1, in <module>
> TypeError: object of type 'NoneType' has no len()
>
>
> As I continued to dig into it I have noticed that when pymssql is being 
> called from web2py nothing is hitting the freetds log. However executing 
> from the shell does. 
>
>
>
>
> On Wednesday, August 5, 2015 at 5:12:19 PM UTC-4, Anthony wrote:
>>
>> Can you go into a web2py shell and do some basic things, like import 
>> pymssql, establish a connection, and issue a basic SQL command?
>>
>> Also, shouldn't you close the connection (i.e., call DestroyConnection) 
>> *before* returning from the function?
>>
>> Anthony
>>
>> On Wednesday, August 5, 2015 at 4:55:14 PM UTC-4, David wrote:
>>>
>>>
>>> I like that idea about the __init__ function and will implement that 
>>> Thanks!!!
>>>
>>> I don't get any errors. I am just getting None returned in both the 
>>> controller and shell even when hard codeing a SamAccountName that works 
>>> within the Python shell. 
>>>  
>>>
>>> On Wednesday, August 5, 2015 at 4:48:03 PM UTC-4, Anthony wrote:
>>>>
>>>> How are you using this in web2py (i.e., where/how does 
>>>> get_GetEmployeeID get called)? Do you get any errors? When you run the 
>>>> web2py shell, how are you starting it, and are you using the same Python 
>>>> interpreter as when you use the basic Python shell?
>>>>
>>>> Also, is the only difference between your two classes the hard-coded 
>>>> database connection string? If so, why not using a single class and just 
>>>> make the connection string an argument of the __init__ function?
>>>>
>>>> Anthony
>>>>
>>>> On Wednesday, August 5, 2015 at 4:17:04 PM UTC-4, David wrote:
>>>>>
>>>>> Here is the first part of the module I was reffering to:
>>>>>
>>>>> import pymssql
>>>>>
>>>>>
>>>>> class HR_DB():
>>>>>     def __init__(self):
>>>>>         self.conn = pymssql.connect(DB Connection Info Removed)
>>>>>
>>>>>     def Execute(self, statement,*args):
>>>>>         cursor = self.conn.cursor()
>>>>>         cursor.execute(statement, args)
>>>>>         result = cursor.fetchall()
>>>>>         cursor.close()
>>>>>         return result
>>>>>
>>>>>     def DestroyConnection(self):
>>>>>         self.conn.close()
>>>>>
>>>>> class Coll_DB():
>>>>>     def __init__(self):
>>>>>         self.conn = pymssql.connect(DB Connection Info Removed)
>>>>>
>>>>>     def Execute(self, statement, *args):
>>>>>         cursor = self.conn.cursor()
>>>>>         cursor.execute(statement,args)
>>>>>         result = cursor.fetchall()
>>>>>         cursor.close()
>>>>>         return result
>>>>>
>>>>>     def DestroyConnection(self):
>>>>>         self.conn.close()
>>>>>
>>>>> def get_GetEmployeeID(SamAccountName):
>>>>>
>>>>>         conn = Coll_DB()
>>>>>         rows = conn.Execute(SQL Removed)
>>>>>         if len(rows) > 0:
>>>>>             return(rows[0]['collid'])
>>>>>         conn.DestroyConnection()
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Again this works just fine calling it outside of web2py.
>>>>>
>>>>> if I run it from the interpreter on the server I am getting the 
>>>>> correct id number. Even using the shell in web2py and issuing the same 
>>>>> commands I am getting nothing. I feel like I am missing something simple
>>>>>
>>>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to