Hello Tim, Thank you for sharing. I've try as your advice but it still return error message as follow, I think something wrong with my odbc setup somehow.
:) db = DAL('mssql://UserName:Password@203.150.29.227\SQLExpress/myDatabase', lazy_tables=True, pool_size=10) RuntimeError: Failure to connect, tried 5 times: Traceback (most recent call last): File "/home/www-data/web2py/gluon/dal.py", line 7562, in __init__ self._adapter = ADAPTERS[self._dbname](**kwargs) File "/home/www-data/web2py/gluon/dal.py", line 3279, in __init__ if do_connect: self.reconnect() File "/home/www-data/web2py/gluon/dal.py", line 627, in reconnect self.connection = f() File "/home/www-data/web2py/gluon/dal.py", line 3277, in connector return self.driver.connect(cnxn,**driver_args) Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)') On Wednesday, November 13, 2013 5:27:55 AM UTC+7, Tim Richardson wrote: > > Here is a working example using server authentication on a server called > win2003, with a sqlserver instance name hcnsql07 and connecting to a > database called hcn using default ports > > (I've added a couple of other parameters for performance. > Investigate lazy_tables, it makes a huge difference. ) > > > db_ps_1TE = DAL('mssql://tim:password@win2003\hcnsql07/hcn', > lazy_tables=True, pool_size=10) > > On Monday, 11 November 2013 07:10:43 UTC+11, Ariya Owam-aram wrote: >> >> Dear all, >> >> I have to connect mssql database which is locate on another server by >> using pyodbc. >> >> It working if connect by using >> >> pyodbc.connect(DNS=dns;UID=user_name;PWD=password) >>> <pyodbc.Connection at 0x391bdc0> >>> >> >> But I can't connect with DAL() >> >> db = >>> DAL("mssql://userName:passw...@203.xxx.xx.xxx\SQLExpress,1433/myDatabase") >> >> >> return error as follow >> >>> Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name >>> not found, and no default driver specified (0) (SQLDriverConnect)') >> >> >> As searching from web2py google group, I also try: >> >> db = >>> DAL("mssql://userName:passw...@203.xxx.xx.xxx\SQLExpress,1433/myDatabase?Driver={FreeTDS}") >> >> >> return error as follow >> >> Error: ('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to >> connect to data source (0) (SQLDriverConnect)') >> >> --------------------------- >> in my /etc/odbc.ini >> >> [TS] >>> Description="ODBC Connection via FreeTDS" >>> Driver=FreeTDS >>> Server=203.xxx.xx.xxx >>> port=1433 >>> Database=myDatabase >> >> --------------------------- >> in my /etc/odbcinst.ini >> >>> [FreeTDS] >>> Description=FreeTDS >>> Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so >>> Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so >> >> --------------------------- >> in my /etc/freetds/freetds.conf >> >> ### Did not change anything ### >> >> --------------------------- >> in my /etc/freetds/tds.driver.template >> >>> [TDS] >>> Description = FreeTDS Driver for Linux & MSSQL on Win32 >>> Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so >>> Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so >> >> --------------------------- >> in my /etc/freetds/tds.dsn.template >> >> [DSN_NAME] >> >>> Description = Descripton of you DSN connection. >>> Driver = TDS >>> Trace = No >>> Database = myDatabase >>> Server = 203.xxx.xx.xxx >>> Port = 1433 >>> TDS_Version = 8.0 >> >> >> >> >> Thank you very much >> Ariya >> >> -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.