[annuaires_pg] Évite de tout planter quand la connexion à PgSQL chie

darcs-hash:20100907125040-ffbb2-efe3bdf518a51a2e2aa6c8d623d76954682b0b22.gz
This commit is contained in:
Nicolas Dandrimont 2010-09-07 14:50:40 +02:00
parent 36bb207274
commit c64c89ddd3

View file

@ -3,13 +3,18 @@
import psycopg2
conn = psycopg2.connect("user=crans dbname=switchs host=pgsql.adm.crans.org")
try:
conn = psycopg2.connect("user=crans dbname=switchs host=pgsql.adm.crans.org")
# Population de la tâble avec les bâtiments
cur = conn.cursor()
cur.execute("SELECT DISTINCT batiment FROM prises")
bat_switchs = [i[0] for i in cur.fetchall()]
except psycopg2.OperationalError:
bat_switchs = ["a", "b", "c", "g", "h", "i", "j", "m", "o", "p"]
# Population de la tâble avec les bâtiments
cur = conn.cursor()
cur.execute("SELECT DISTINCT batiment FROM prises")
bat_switchs = [i[0] for i in cur.fetchall()]
bat_manuels = []