File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
python/plugins/db_manager/db_plugins/postgis Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 28
28
from ..connector import DBConnector
29
29
from ..plugin import ConnectionError , DbError , Table
30
30
31
+ import os
31
32
import psycopg2
32
33
import psycopg2 .extensions
33
34
# use unicode!
@@ -42,14 +43,11 @@ class PostGisDBConnector(DBConnector):
42
43
def __init__ (self , uri ):
43
44
DBConnector .__init__ (self , uri )
44
45
45
- self .host = uri .host ()
46
- self .port = uri .port ()
47
- self .dbname = uri .database ()
48
- self .user = uri .username ()
49
- self .passwd = uri .password ()
50
-
51
- if self .dbname == '' or self .dbname is None :
52
- self .dbname = self .user
46
+ self .host = uri .host () or os .environ .get ('PGHOST' )
47
+ self .port = uri .port () or os .environ .get ('PGPORT' )
48
+ self .user = uri .username () or os .environ .get ('PGUSER' ) or os .environ .get ('USER' )
49
+ self .dbname = uri .database () or os .environ .get ('PGDATABASE' ) or self .user
50
+ self .passwd = uri .password () or os .environ .get ('PGPASSWORD' )
53
51
54
52
try :
55
53
self .connection = psycopg2 .connect ( self ._connectionInfo ().encode ('utf-8' ) )
You can’t perform that action at this time.
0 commit comments