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.


On Wednesday, August 5, 2015 at 1:47:41 PM UTC-4, Anthony wrote:
>
> Hard to say without seeing any code or any details about how you have 
> deployed and are testing the web2py code.
>
> On Wednesday, August 5, 2015 at 1:39:14 PM UTC-4, David wrote:
>>
>> Hello,
>>
>> I am porting some of old legacy web apps (very legacy) to web2py. I am 
>> trying to connect to external databases via module we have tested and used 
>> elsewhere but it does not seem to work at all in web2py. For example, if we 
>> try to use a function inside this module to find the employee id of a 
>> person via username it works on the webserver on the command line by 
>> calling: CustomModule.GetEmployeeID('someusername'). However this won't 
>> work in a controller or the shell within web2py. Does anyone have any ideas 
>> what might be causing this?
>>
>> Thanks,
>>
>> David
>>
>>

-- 
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