Niphlod,

You right, I didn't have to reimport the pyodbc.  I'm connecting to the 
database now, but still getting an error.

I think it has something to do with how I define the field RowVersion. 
 RowVersion is defined as a timestamp data type in MS SQL Server 2012.  How 
do I define that in the define_table function?



On Friday, August 23, 2013 1:44:15 PM UTC-5, Niphlod wrote:
>
> seems that you're using the binary version. May I ask why do you need to 
> reimport pyodbc on your own ?
> Why not just using db = DAL("mssql:// etc etc etc ") ?
>
> On Friday, August 23, 2013 8:09:45 PM UTC+2, GregD wrote:
>>
>> Hi,
>>
>> We're new to Web2py and starting to use it more and more to meet 
>> customer's demand for Web Apps.  Currently, we need to create a few forms 
>> to retrieve info from production database system.
>>
>> Our environment is as follows:
>> Windows Server 2008 R2
>> SQL Server 2012 Standard
>> IIS 7.0
>>
>> We've downloaded web2py and have forms created.  However, we are having 
>> issues connecting to existing SQL Server database.  Our DAL is as follows:
>>
>> import pyodbc
>> from gluon.dal import MSSQLAdapter
>> if not (MSSQLAdapter.driver):
>>   MSSQLAdapter.driver = pyodbc
>> db = pyodbc.connect("DRIVER={SQL 
>> SERVER};SERVER=localhost\sqlexpress2012;DATABASE=Customer;UID=sa;PWD=***")
>>
>> We've defined the tables as follows:
>>
>> db.define_table('Locals', 
>>     Field('id', 'int'),
>>     Field('Name', 'str'),
>>     Field('Logo', 'buffer'),
>>     Field('ActiveFlag', 'bool' ),
>>     Field('RowVersion', 'datetime.datetime'),
>>     Field('Address1', 'str'),
>>     Field('Address2', 'str'),
>>     Field('City', 'str'),
>>     Field('State', 'str'),
>>     Field('Zip', 'str'),
>>     Field('Phone', 'str'),
>>     Field('PrimaryContact', 'str'),
>>     Field('SecondaryContact', 'str'),
>>     Field('FaxTitle', 'str'),
>>     Field('TestingName', 'str'),
>>     Field('RecieveParts', 'str'),
>>     primarykey=[id],
>>     migrate=False)
>>
>> however, when we attempt to connect to database from admin page we get ...
>>
>> Traceback (most recent call last):
>>   File "/home/mdipierro/make_web2py/web2py/gluon/restricted.py", line 212, 
>> in restricted
>>   File "C:/web2py/applications/Reciprocity/models/db.py" 
>> <http://192.168.1.125:8000/admin/default/edit/Reciprocity/models/db.py>, 
>> line 61, in <module>
>> AttributeError: 'pyodbc.Connection' object has no attribute 'define_table'
>>
>> It appears there is no define_table method in pyodbc, is that correct?  If 
>> so, how should we model exsiting SQL Server tables using pyodbc?
>>
>>

-- 

--- 
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/groups/opt_out.

Reply via email to