Browse Source

ecn-robots: removed some superfluous strip()s from pgdb.py

master
Nagy Karoly Gabriel 15 years ago
parent
commit
cdaded1f63
1 changed files with 8 additions and 8 deletions
  1. +8
    -8
      pgdb.py

+ 8
- 8
pgdb.py

@ -46,7 +46,7 @@ class Db(object):
information['size'] = self._runsql("SELECT pg_size_pretty(pg_database_size('"+self._name+"'));").strip() information['size'] = self._runsql("SELECT pg_size_pretty(pg_database_size('"+self._name+"'));").strip()
information['encoding'], information['collation'], \ information['encoding'], information['collation'], \
information['ctype'] = self._runsql("""SELECT pg_encoding_to_char(encoding), information['ctype'] = self._runsql("""SELECT pg_encoding_to_char(encoding),
datcollate, datctype FROM pg_database WHERE datname='"""+self._name+"';").strip().split('|')
datcollate, datctype FROM pg_database WHERE datname='"""+self._name+"';").split('|')
return information return information
@property @property
@ -57,14 +57,14 @@ class Db(object):
def user_exists(self, user): def user_exists(self, user):
sql = "SELECT rolname FROM pg_authid WHERE rolname = '"+user+"';" sql = "SELECT rolname FROM pg_authid WHERE rolname = '"+user+"';"
u = self._runsql(sql).strip()
u = self._runsql(sql)
if (u == ""): if (u == ""):
return False return False
return True return True
def db_exists(self, xdb): def db_exists(self, xdb):
sql = "SELECT datname FROM pg_database WHERE datname = '"+xdb+"';" sql = "SELECT datname FROM pg_database WHERE datname = '"+xdb+"';"
d = self._runsql(sql).strip()
d = self._runsql(sql)
if (d == ""): if (d == ""):
return False return False
return True return True
@ -112,8 +112,8 @@ class Db(object):
return usrlist return usrlist
def _test(): def _test():
#test = Db(u'postgres')
#print test.info['encoding'], test.info['collation'], test.info['ctype']
test = Db(u'postgres')
print test.info['encoding'], test.info['collation'], test.info['ctype']
#print test.owner #print test.owner
#print test.connections #print test.connections
#print "User aaa is ",test.user_exists("aaa") #print "User aaa is ",test.user_exists("aaa")
@ -130,9 +130,9 @@ def _test():
#print test2.owner #print test2.owner
#test2.owner = u'karasz' #test2.owner = u'karasz'
#print test2.owner #print test2.owner
test = Db(u'aaa')
test.create(u'postgres', u'en_US.UTF-8', u'en_US.UTF-8')
print test.dump('/tmp/aaa.gz',u'p')
#test = Db(u'aaa')
#test.create(u'postgres', u'en_US.UTF-8', u'en_US.UTF-8')
#print test.dump('/tmp/aaa.gz',u'p')
#test.delete() #test.delete()
if __name__ == '__main__': if __name__ == '__main__':
_test() _test()

Loading…
Cancel
Save