[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH] Now really add the gisdb module
From: |
Thomas Petazzoni |
Subject: |
[Maposmatic-dev] [PATCH] Now really add the gisdb module |
Date: |
Sun, 25 Mar 2012 22:16:27 +0200 |
Needed for the previous commit. oops.
Signed-off-by: Thomas Petazzoni <address@hidden>
---
www/maposmatic/gisdb.py | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
create mode 100644 www/maposmatic/gisdb.py
diff --git a/www/maposmatic/gisdb.py b/www/maposmatic/gisdb.py
new file mode 100644
index 0000000..e631b18
--- /dev/null
+++ b/www/maposmatic/gisdb.py
@@ -0,0 +1,23 @@
+import psycopg2
+import www.settings
+
+db = None
+
+def get():
+ global db
+ if db:
+ return db
+
+ try:
+ db = psycopg2.connect("dbname='%s' user='%s' host='%s' password='%s'
port='%s'" %
+ (www.settings.GIS_DATABASE_NAME,
+ www.settings.GIS_DATABASE_USER,
+ www.settings.GIS_DATABASE_HOST,
+ www.settings.GIS_DATABASE_PASSWORD,
+ www.settings.GIS_DATABASE_PORT))
+ except psycopg2.OperationalError, e:
+ l.warning("Could not connect to the PostGIS database: %s" %
+ str(e)[:-1])
+ return None
+
+ return db
--
1.7.4.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Maposmatic-dev] [PATCH] Now really add the gisdb module,
Thomas Petazzoni <=