# Example shows use of AutoFill Cursor to break RdbHost record limit. # modified from pgoids.py -- Example using the API Classes (ver 2.0.2) with the s role from rdbhdb import rdbhdb as db authcode = 'KF7IUQPlwfSth4sBvjdqqanHkojAZzEjMshrkfEV0O53yz6w6v' conn=db.connect('s000015', authcode=authcode) conn.set_autorefill() dc = conn.cursor() q = "SELECT oid, typname, typelem FROM pg_type WHERE typtype = \'b\' ORDER BY oid" for i in range(124): row = dc.fetchone() print row
def _connect(self): try: return rdbhdb.connect(*self.connect_args, **self.connect_kw_args) except AttributeError: self.fail("No connect method found in self.driver module")
for cycle in range(5): n = random.randint(0, 9) rows_added = rows_added + [n] for i in range(n): q = "INSERT INTO thread%s VALUES (%s, %s, %s, %s)" %(table_suffix, cycle, str(i), i, float(i)) try: cur.execute(q) except: raise DatabaseError('while inserting rows into table thread%s'%table_suffix) cur.close() ROWS_ADDED[table_suffix] = rows_added return role = 's000015' authcode = 'KF7IUQPlwfSth4sBvjdqqanHkojAZzEjMshrkfEV0O53yz6w6v' conn=db.connect(role, authcode=authcode) ROWS_ADDED = {} THREADS = ('I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X') qsetup = "CREATE TABLE thread%s (cycle int4, name text, value1 int4, value2 float)" qteardown = "DROP TABLE IF EXISTS thread%s" cur = conn.cursor() for name in THREADS: #cur.execute(qsetup + '%' + name) cur.execute(qteardown%name) cur.execute(qsetup%name) cur.close() threads = []
#!/usr/bin/env python from rdbhdb.rdbhdb import connect authcode = "KF7IUQPlwfSth4sBvjdqqanHkojAZzEjMshrkfEV0O53yz6w6v" conn = connect("s000015", authcode=authcode) curs = conn.cursor() curs.execute("""DROP TABLE atable""") curs.execute( """CREATE TABLE atable ( name char(8), value float)""" ) curs.execute("INSERT INTO atable VALUES ('one', 1.0)") curs.execute("INSERT INTO atable VALUES ('two', 2.0)") conn.commit()