48 |
self.user = user |
self.user = user |
49 |
self.password = password |
self.password = password |
50 |
self.dbtype = dbtype |
self.dbtype = dbtype |
51 |
|
self.connect() |
52 |
|
|
53 |
|
def connect(self): |
54 |
|
"""Internal: Establish the database connection""" |
55 |
params = [] |
params = [] |
56 |
for name in ("host", "port", "dbname", "user", "password"): |
for name in ("host", "port", "dbname", "user", "password"): |
57 |
val = getattr(self, name) |
val = getattr(self, name) |
71 |
else: |
else: |
72 |
raise ValueError("Can't determine postgres type of geometries") |
raise ValueError("Can't determine postgres type of geometries") |
73 |
|
|
74 |
|
def BriefDescription(self): |
75 |
|
"""Return a brief, one-line description of the connection |
76 |
|
|
77 |
|
The return value is suitable for a list box of all database |
78 |
|
connections. |
79 |
|
""" |
80 |
|
return ("postgis://%(user)s@%(host)s:%(port)s/%(dbname)s" |
81 |
|
% self.__dict__) |
82 |
|
|
83 |
def Close(self): |
def Close(self): |
84 |
"""Close the database connection""" |
"""Close the database connection""" |
85 |
self.connection.close() |
self.connection.close() |