Hello web2py community,
I have noted that the DAL does not suppor the follow kind of underlying
connection in python:
import psycopg2
conn_string = "host='/tmp' dbname='foobar_db' user='foo' password='bar'"
conn = psycopg2.connect(conn_string)
cursor = conn.cursor()
cursor.execute("SELECT * FROM foobar_table")
records = cursor.fetchall()
That is, the syntax
db = DAL("postgres://foo:bar@localhost:5432/foobar_db")
works but not
db = DAL("postgres://foo:bar@/tmp/foobar_database")
I'd like to suggest that the line in DAL.py
[1]
re.compile('^(?P<user>[^:@]+)(\:(?P<password>[^@]*))?@(?P<host>[^\:@/]+)(\:(?P<port>[0-9]+))?/(?P<db>[^\?]+)(\?sslmode=(?P<sslmode>.+))?$').match(uri)
Can be
[2]
re.compile('^(?P<user>[^:@]+)(\:(?P<password>[^@]*))?@(?P<host>[^\:@]+)(\:(?P<port>[0-9]+))?/(?P<db>[^\?]+)(\?sslmode=(?P<sslmode>.+))?$').match(uri)
Where the 70th character, "/" in [1] is removed from the Regular Expression
pattern to produce [2] (in [1] the pattern requires that what follows @ not
start with "/" while that could actually be valid syntax as aforementioned
above).
Best regards,
B