/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/postgisdb.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/postgisdb.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1660 by bh, Tue Aug 26 12:54:45 2003 UTC revision 1662 by bh, Wed Aug 27 13:51:01 2003 UTC
# Line 209  class PostGISTable: Line 209  class PostGISTable:
209          cursor.execute("SELECT count(*) FROM %s" % self.tablename)          cursor.execute("SELECT count(*) FROM %s" % self.tablename)
210          return cursor.fetchone()[0]          return cursor.fetchone()[0]
211    
212      def ReadRowAsDict(self, row):      def RowIdToOrdinal(self, gid):
213            """Return the row ordinal given its id"""
214          cursor = self.db.cursor()          cursor = self.db.cursor()
215          cursor.execute(self.query_stmt + " LIMIT 1 OFFSET %d" % row)          cursor.execute("SELECT count(*) FROM %s WHERE gid < %d;"
216                           % (self.tablename, gid))
217            return cursor.fetchone()[0]
218    
219        def RowOrdinalToId(self, num):
220            """Return the rowid for given its ordinal"""
221            cursor = self.db.cursor()
222            cursor.execute("SELECT gid FROM %s LIMIT 1 OFFSET %d;"
223                           % (self.tablename, num))
224            return cursor.fetchone()[0]
225    
226        def ReadRowAsDict(self, row, row_is_ordinal = 0):
227            cursor = self.db.cursor()
228            if row_is_ordinal:
229                stmt = self.query_stmt + " LIMIT 1 OFFSET %d" % row
230            else:
231                stmt = self.query_stmt + " WHERE gid = %d" % row
232            cursor.execute(stmt)
233          result = {}          result = {}
234          for col, value in zip(self.columns, cursor.fetchone()):          for col, value in zip(self.columns, cursor.fetchone()):
235              result[col.name] = value              result[col.name] = value
236          return result          return result
237    
238      def ReadValue(self, row, col):      def ReadValue(self, row, col, row_is_ordinal = 0):
239          cursor = self.db.cursor()          cursor = self.db.cursor()
240          cursor.execute("SELECT %s FROM %s LIMIT 1 OFFSET %d" %          if row_is_ordinal:
241                         (self.column_map[col].name, self.tablename, row))              stmt = ("SELECT %s FROM %s LIMIT 1 OFFSET %d" %
242                        (self.column_map[col].name, self.tablename, row))
243            else:
244                stmt = ("SELECT %s FROM %s WHERE gid = %d" %
245                        (self.column_map[col].name, self.tablename, row))
246            cursor.execute(stmt)
247          return cursor.fetchone()[0]          return cursor.fetchone()[0]
248    
249      def ValueRange(self, col):      def ValueRange(self, col):

Legend:
Removed from v.1660  
changed lines
  Added in v.1662

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26