Thread: [SQLObject] possible bug in pymssql make_conn_str
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Robert A. <rob...@gm...> - 2013-08-16 00:57:45
|
Hello. There is a code in sqlobject/mssql/mssqlconnection.py: else: # pymssql self.dbconnection = sqlmodule.connect sqlmodule.Binary = lambda st: str(st) # don't know whether pymssql uses unicode self.usingUnicodeStrings = False self.make_conn_str = lambda keys: \ ["", keys.user, keys.password, keys.host, keys.db] However, pymssql.connect declaration is following: def connect(server='.', user='', password='', database='', timeout=0, login_timeout=60, charset=None, as_dict=False, host='', appname=None, port='1433') So seems make_conn_str produces wrong set of params which throws: pymssql.InterfaceError: Connection to the database failed for an unknown reason. (because actual host value is empty). I've updated it like that: self.make_conn_str = lambda keys: \ [".", keys.user, keys.password, keys.db, 0, 60, None, False, keys.host, None, keys.port] and things started to work. Thanks. |
From: Oleg B. <ph...@ph...> - 2013-08-16 01:22:25
|
On Thu, Aug 15, 2013 at 05:57:37PM -0700, Robert Ayrapetyan <rob...@gm...> wrote: > There is a code in sqlobject/mssql/mssqlconnection.py: > > else: # pymssql > self.dbconnection = sqlmodule.connect > sqlmodule.Binary = lambda st: str(st) > # don't know whether pymssql uses unicode > self.usingUnicodeStrings = False > self.make_conn_str = lambda keys: \ > ["", keys.user, keys.password, keys.host, keys.db] > > However, pymssql.connect declaration is following: > > def connect(server='.', user='', password='', database='', timeout=0, > login_timeout=60, charset=None, as_dict=False, > host='', appname=None, port='1433') > > So seems make_conn_str produces wrong set of params which throws: > > pymssql.InterfaceError: Connection to the database failed for an unknown > reason. > > (because actual host value is empty). > > I've updated it like that: > > self.make_conn_str = lambda keys: \ > [".", keys.user, keys.password, keys.db, 0, 60, > None, False, keys.host, None, keys.port] > > and things started to work. Thank you. I don't use MSSQL so I cannot test it. I will apply and commit your code later. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Robert A. <rob...@gm...> - 2013-08-16 18:19:44
|
Not getting own emails and replies (all mailing list settings are set by default, however I found a reply in a mail archive here: http://sourceforge.net/mailarchive/forum.php?forum_name=sqlobject-discuss&max_rows=25&style=nested&viewmonth=201308). Anyway, instead of [".", keys.user, keys.password, keys.db, 0, 60, None, False, keys.host, None, keys.port] for def connect(server='.', user='', password='', database='', timeout=0, login_timeout=60, charset=None, as_dict=False, host='', appname=None, port='1433') (which works fine for me) it would be better to pass only user, password, database, host and port (if set explicitly) (leaving default vals for other params). I'm not a python guru and have no idea how to implement this via dynamically generated list of params (similarly to how it was). On Thu Aug 15 17:57:37 2013, Robert Ayrapetyan wrote: > Hello. > > There is a code in sqlobject/mssql/mssqlconnection.py: > > else: # pymssql > self.dbconnection = sqlmodule.connect > sqlmodule.Binary = lambda st: str(st) > # don't know whether pymssql uses unicode > self.usingUnicodeStrings = False > self.make_conn_str = lambda keys: \ > ["", keys.user, keys.password, keys.host, keys.db] > > However, pymssql.connect declaration is following: > > def connect(server='.', user='', password='', database='', timeout=0, > login_timeout=60, charset=None, as_dict=False, > host='', appname=None, port='1433') > > So seems make_conn_str produces wrong set of params which throws: > > pymssql.InterfaceError: Connection to the database failed for an > unknown reason. > > (because actual host value is empty). > > I've updated it like that: > > self.make_conn_str = lambda keys: \ > [".", keys.user, keys.password, keys.db, 0, 60, > None, False, keys.host, None, keys.port] > > and things started to work. > > Thanks. |
From: Oleg B. <ph...@ph...> - 2013-08-16 20:03:12
|
Hi! Please avoid top-posting. You know the problem: A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? My answer is below. On Fri, Aug 16, 2013 at 11:19:35AM -0700, Robert Ayrapetyan <rob...@gm...> wrote: > Not getting own emails and replies (all mailing list settings are set > by default, > however I found a reply in a mail archive here: > http://sourceforge.net/mailarchive/forum.php?forum_name=sqlobject-discuss&max_rows=25&style=nested&viewmonth=201308). > > Anyway, instead of > > [".", keys.user, keys.password, keys.db, 0, 60, None, False, keys.host, > None, keys.port] > > for > > def connect(server='.', user='', password='', database='', timeout=0, > login_timeout=60, charset=None, as_dict=False, > host='', appname=None, port='1433') > > (which works fine for me) > > it would be better to pass only user, password, database, host and port > (if set explicitly) > (leaving default vals for other params). > I'm not a python guru and have no idea how to implement this via > dynamically generated list of params (similarly to how it was). I changed the generation of parameters for pymssql. Committed in the revisions 4644, 4645 in branch 1.5 (code and news), 4646 in the trunk. Can you test the patch? Or do you want me to roll out a beta release? Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2013-08-19 12:25:00
|
On Sat, Aug 17, 2013 at 12:02:52AM +0400, Oleg Broytman <ph...@ph...> wrote: > I changed the generation of parameters for pymssql. Committed in the > revisions 4644, 4645 in branch 1.5 (code and news), 4646 in the trunk. > Can you test the patch? Or do you want me to roll out a beta release? Minor update at revisions 4647, 4648. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Robert A. <rob...@gm...> - 2013-08-20 02:24:04
|
Unexpectedly it started to use adodbapi driver by default (previously it somehow was pymssql), after passing driver="pymssql" to "connectionForURI" things started to work as expected. On Mon Aug 19 05:24:39 2013, Oleg Broytman wrote: > On Sat, Aug 17, 2013 at 12:02:52AM +0400, Oleg Broytman <ph...@ph...> wrote: >> I changed the generation of parameters for pymssql. Committed in the >> revisions 4644, 4645 in branch 1.5 (code and news), 4646 in the trunk. >> Can you test the patch? Or do you want me to roll out a beta release? > > Minor update at revisions 4647, 4648. > > Oleg. |
From: Oleg B. <ph...@ph...> - 2013-08-20 07:54:09
|
On Mon, Aug 19, 2013 at 07:23:53PM -0700, Robert Ayrapetyan <rob...@gm...> wrote: > Unexpectedly it started to use adodbapi driver by default > (previously it somehow was pymssql), > after passing driver="pymssql" to "connectionForURI" things started > to work as expected. > > On Mon Aug 19 05:24:39 2013, Oleg Broytman wrote: > >On Sat, Aug 17, 2013 at 12:02:52AM +0400, Oleg Broytman <ph...@ph...> wrote: > >> I changed the generation of parameters for pymssql. Committed in the > >>revisions 4644, 4645 in branch 1.5 (code and news), 4646 in the trunk. > >> Can you test the patch? Or do you want me to roll out a beta release? > > > > Minor update at revisions 4647, 4648. Thank you for the report! Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |