From 2ad8840b29da8fd8fc8d1fc5bc4121292981def2 Mon Sep 17 00:00:00 2001 From: Nagy Karoly Gabriel Date: Mon, 12 Apr 2010 14:47:29 +0300 Subject: [PATCH] ecn-robots: more whitespace cleaning on pgdb.py --- pgdb.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pgdb.py b/pgdb.py index d58e2cc..cfc5a1f 100644 --- a/pgdb.py +++ b/pgdb.py @@ -5,7 +5,7 @@ import psycopg2 import psycopg2.extensions class Db(object): - + def __init__(self,name): self._name = name self.conn = psycopg2.connect("dbname='postgres' user='postgres' host= \ @@ -27,10 +27,10 @@ class Db(object): self.cursor.execute(given_sql) try: out = self.cursor.fetchall() - except Exception,e: + except Exception,e: out = "Exception " +str(e)+" ocured" return out - + def _get_owner(self): sql = "SELECT pg_get_userbyid(datdba) FROM pg_database WHERE datname = \ '"+self.sanitize(self._name)+"';" @@ -41,7 +41,7 @@ class Db(object): sql = "ALTER DATABASE "+self._name+" OWNER TO "+self.sanitize(owner)+";" own = self._runsql(sql) return own - + db_owner = property(_get_owner, _set_owner) @property @@ -57,7 +57,7 @@ class Db(object): information['size'] = self._runsql("SELECT pg_size_pretty( \ pg_database_size('"+self.sanitize( self._name)+"'));") - inf = self._runsql("""SELECT pg_encoding_to_char(encoding), + inf = self._runsql("""SELECT pg_encoding_to_char(encoding), datcollate, datctype FROM pg_database WHERE datname='""" +self._name+"';") information['encoding'] = inf[0][0] @@ -71,7 +71,7 @@ class Db(object): '"+self.sanitize(self._name)+"';" cncs = self._runsql(sql) return cncs - + def user_exists(self, user): sql = "SELECT rolname FROM pg_authid WHERE rolname = \ '"+self.sanitize(user)+"';" @@ -147,7 +147,7 @@ class Db(object): sql = "DROP ROLE IF EXISTS "+self.sanitize(us)+";" usrd = self._runsql(sql) return usrd - + def sanitize(self,s): mset = '0123456789ABCDEFGHIJKLMNOPRSTUVXYZabcdefghijklmnoprstuvxyz-_.' return ''.join([c for c in s if c in mset])