def QueryBlock(self, p_sql, p_blocksize, p_alltypesstr=False):
try:
if self.v_con is None:
raise Spartacus.Database.Exception('This method should be called in the middle of Open() and Close() calls.')
else:
if self.v_start:
self.v_cur.execute(p_sql)
v_table = DataTable()
if self.v_cur.description:
for c in self.v_cur.description:
v_table.Columns.append(c[0])
if p_blocksize > 0:
v_table.Rows = self.v_cur.fetchmany(p_blocksize)
else:
v_table.Rows = self.v_cur.fetchall()
if p_alltypesstr:
for i in range(0, len(v_table.Rows)):
for j in range(0, len(v_table.Columns)):
if v_table.Rows[i][j] != None:
v_table.Rows[i][j] = str(v_table.Rows[i][j])
else:
v_table.Rows[i][j] = ''
if self.v_start:
self.v_start = False
return v_table
except Spartacus.Database.Exception as exc:
raise exc
except psycopg2.Error as exc:
raise Spartacus.Database.Exception(str(exc))
except Exception as exc:
raise Spartacus.Database.Exception(str(exc))
评论列表
文章目录