Ticket #1218 (new bug)

Opened 21 months ago

Fix for connecting to postgres server

Reported by: bsloane Owned by:
Milestone: Component: library
Severity: minor Keywords:
Cc: Blocking:
Blocked By:

Description

Connecting to a postgres server (9.1.4) fails on Fedora 17:

>>> from Orange.data.sql import *
/usr/lib64/python2.7/site-packages/Orange/network/__init__.py:59: UserWarning: Warning: some features are disabled. Install networkx to use the 'Orange.network' module.
  warnings.warn("Warning: some features are disabled. Install networkx to use the 'Orange.network' module.")
>>> r=SQLReader()
>>> r.connect("postgres://user:pass@127.0.0.1")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/Orange/data/sql.py", line 153, in connect
    (self.quirks, self.conn) = _connection(uri)
  File "/usr/lib64/python2.7/site-packages/Orange/data/sql.py", line 119, in _connection
    return (quirks, dbmod.connect(**dbArgDict))
  File "/usr/lib64/python2.7/site-packages/psycopg2/__init__.py", line 179, in connect
    connection_factory=connection_factory, async=async)
psycopg2.OperationalError: invalid connection option "passwd"

>>> r.connect("postgres://user@127.0.0.1")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/Orange/data/sql.py", line 153, in connect
    (self.quirks, self.conn) = _connection(uri)
  File "/usr/lib64/python2.7/site-packages/Orange/data/sql.py", line 119, in _connection
    return (quirks, dbmod.connect(**dbArgDict))
  File "/usr/lib64/python2.7/site-packages/psycopg2/__init__.py", line 179, in connect
    connection_factory=connection_factory, async=async)
psycopg2.OperationalError: invalid connection option "db"

I fixed this my modifying the postgres case in Orange/data/sql.py as follows:

        if schema == 'postgres':
            import psycopg2 as dbmod
            argTrans["database"] = "database" #changed
            argTrans["password"]="password"   #added
            quirks = __PostgresQuirkFix(dbmod)
            quirks.parameter = "%s"
Note: See TracTickets for help on using tickets.