예제 #1
0
파일: pg_schemas.py 프로젝트: shon/cowspa
 def load_schema(self, cur):
     self.check_tablename()
     q = "select 1 from information_schema.tables where table_name = %s"
     cur.execute(q, (self.table_name,))
     if not cur.fetchone():
         self.create_table(cur)
     q = "select column_name, column_default, character_maximum_length from INFORMATION_SCHEMA.COLUMNS where table_name=%s"
     cur.execute(q, (self.table_name,))
     cols = cur.fetchall()
     schema = {}
     for name, column_default, max_len in cols:
         schema[name] = odict(name=name, max_len=max_len)
         if name == 'id' and column_default == "nextval('%s_id_seq'::regclass)" % self.table_name:
             self.auto_id = True
     self.schema = schema
예제 #2
0
파일: stores.py 프로젝트: shon/cowspa
 def fetch_one_by(self, *args, **kw):
     try:
         super(UIPref, self).fetch_one_by(*args, **kw)
     except IndexError, err:
         return odict(self.defaults)