Skip to content

Commit

Permalink
add util method to fetch database properties
Browse files Browse the repository at this point in the history
  • Loading branch information
akrherz committed Feb 11, 2015
1 parent a126b69 commit 134cee3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pyiem/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
This module contains utility functions used by various parts of the codebase.
"""
import psycopg2


def get_properties():
"""Fetch the properties set"""
pgconn = psycopg2.connect(database='mesosite', host='iemdb')
cursor = pgconn.cursor()
cursor.execute("""SELECT propname, propvalue from properties""")
res = {}
for row in cursor:
res[row[0]] = row[1]
return res


def drct2text(drct):
"""Convert an degree value to text representation of direction.
Expand Down

0 comments on commit 134cee3

Please sign in to comment.