annuaires_pg: utilise db django
This commit is contained in:
parent
937aab00af
commit
1df794db38
1 changed files with 7 additions and 7 deletions
|
@ -31,7 +31,7 @@ def _need_conn(f):
|
|||
if attempts:
|
||||
# Attend un peu avant de reessayer
|
||||
time.sleep(delay)
|
||||
conn = psycopg2.connect(user='crans', database='switchs',
|
||||
conn = psycopg2.connect(user='crans_ro', database='django',
|
||||
host=host)
|
||||
return f(*args, **kwargs)
|
||||
except psycopg2.OperationalError:
|
||||
|
@ -58,14 +58,14 @@ def chbre_prises(batiment, chambre = None):
|
|||
if chambre:
|
||||
chambre = chambre.lower()
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT prise_crans FROM prises WHERE (batiment, chambre) = (%s, %s)", (batiment, chambre))
|
||||
cur.execute("SELECT prise_crans FROM prises_prise WHERE (batiment, chambre) = (%s, %s)", (batiment, chambre))
|
||||
try:
|
||||
return "%03d" % cur.fetchone()[0]
|
||||
except TypeError:
|
||||
raise ChbreNotFound("Chambre inexistante bat %r, chbre %r" % (batiment, chambre))
|
||||
else:
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT chambre, prise_crans FROM prises WHERE batiment = %s", batiment)
|
||||
cur.execute("SELECT chambre, prise_crans FROM prises_prise WHERE batiment = %s", batiment)
|
||||
ret = {}
|
||||
for chambre, prise_crans in cur.fetchall():
|
||||
ret[chambre] = "%03d" % prise_crans
|
||||
|
@ -79,7 +79,7 @@ def chbre_commentaire(batiment, chambre):
|
|||
global conn
|
||||
batiment = batiment.lower()
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT commentaire FROM prises WHERE (batiment, chambre) = (%s,%s)", (batiment, chambre))
|
||||
cur.execute("SELECT commentaire FROM prises_prise WHERE (batiment, chambre) = (%s,%s)", (batiment, chambre))
|
||||
try:
|
||||
return cur.fetchone()[0]
|
||||
except TypeError:
|
||||
|
@ -91,14 +91,14 @@ def reverse(batiment, prise = None):
|
|||
batiment = batiment.lower()
|
||||
if prise:
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT chambre FROM prises WHERE (batiment, prise_crans) = (%s, %s)", (batiment, int(prise)))
|
||||
cur.execute("SELECT chambre FROM prises_prise WHERE (batiment, prise_crans) = (%s, %s)", (batiment, int(prise)))
|
||||
try:
|
||||
return [chbre for (chbre,) in cur.fetchall()]
|
||||
except TypeError:
|
||||
raise ValueError("Prise %s inexistante" % prise)
|
||||
else:
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT chambre, prise_crans FROM prises WHERE batiment = %s", batiment)
|
||||
cur.execute("SELECT chambre, prise_crans FROM prises_prise WHERE batiment = %s", batiment)
|
||||
ret = {}
|
||||
for chambre, prise_crans in cur.fetchall():
|
||||
try:
|
||||
|
@ -115,7 +115,7 @@ def is_connected(batiment, chambre):
|
|||
batiment = batiment.lower()
|
||||
chambre = chambre.lower()
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT cablage_effectue FROM prises WHERE (batiment, chambre) = (%s, %s)", (batiment, chambre))
|
||||
cur.execute("SELECT cablage_effectue FROM prises_prise WHERE (batiment, chambre) = (%s, %s)", (batiment, chambre))
|
||||
return cur.fetchone()[0]
|
||||
|
||||
# Prises d'uplink, de machines du crans / Prises d'utilité CRANS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue