def parseDatum(input): rv=None if len(input) > 0: t=TigerTypes.getType(input[0]) rv=t.parse(input) return rv
def parseDatum(input): rv = None if len(input) > 0: t = TigerTypes.getType(input[0]) rv = t.parse(input) return rv
def count(self, fn): rv = 0 zf = zipfile.ZipFile(fn) bytype = dict() for file in zf.namelist(): zi = zf.getinfo(file) t = TigerTypes.getType(file[-1]) nr = zi.file_size / (t.recordSize() + 2) bytype[file[-1]] = nr rv = rv + nr return rv, bytype
def count(self, fn): rv=0 zf=zipfile.ZipFile(fn) bytype=dict() for file in zf.namelist(): zi=zf.getinfo(file) t=TigerTypes.getType(file[-1]) nr=zi.file_size/(t.recordSize()+2) bytype[file[-1]]=nr rv = rv + nr return rv, bytype
print os.times() c.execute("commit") successful=1 finally: if not successful: print "Rolling back." c.execute('rollback') totalcount=0 sizein=dict() for f in argv[1:]: zf=zipfile.ZipFile(f) for file in zf.namelist(): zi=zf.getinfo(file) t=TigerTypes.getType(file[-1]) nr=zi.file_size/(t.recordSize()+2) totalcount = totalcount + nr if sizein.has_key(f): sizein[f] = sizein[f] + nr else: sizein[f] = nr print "Need to load " + str(totalcount) + " records." dbconn=psycopg.connect('dbname=tiger host=disk port=2345 user=dustin ' \ + 'password=blahblah') c=dbconn.cursor() stats=Stats.Stats(totalcount)
c.execute("commit") successful = 1 finally: if not successful: print "Rolling back." c.execute('rollback') totalcount = 0 sizein = dict() for f in argv[1:]: zf = zipfile.ZipFile(f) for file in zf.namelist(): zi = zf.getinfo(file) t = TigerTypes.getType(file[-1]) nr = zi.file_size / (t.recordSize() + 2) totalcount = totalcount + nr if sizein.has_key(f): sizein[f] = sizein[f] + nr else: sizein[f] = nr print "Need to load " + str(totalcount) + " records." dbconn=psycopg.connect('dbname=tiger host=disk port=2345 user=dustin ' \ + 'password=blahblah') c = dbconn.cursor() stats = Stats.Stats(totalcount)
import TigerTypes import string print """ -- This is how we keep up with what we've seen. create table loaded_files ( filename text ); create unique index load_filesbyname on loaded_files(filename); """ for type in (1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'C', 'H', 'I', 'P', 'R', 'S','Z'): tablename = "type_" + str(type).lower() print "-- Doing " + tablename type=TigerTypes.getType(str(type)) tc="create table " + tablename + " (\n" types=list() for field in type.getFields()[1:]: tmp="\t -- " + field.getDescription() + "\n" tmp+="\t" + field.getName() + " " if field.isNumeric(): if len(field) < 5: tmp+="smallint" else: tmp+="integer" else: tmp+="varchar(" + str(len(field)) + ")" if not field.isNullable(): tmp+=" not null"
import string print """ -- This is how we keep up with what we've seen. create table loaded_files ( filename text ); create unique index load_filesbyname on loaded_files(filename); """ for type in (1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'C', 'H', 'I', 'P', 'R', 'S', 'Z'): tablename = "type_" + str(type).lower() print "-- Doing " + tablename type = TigerTypes.getType(str(type)) tc = "create table " + tablename + " (\n" types = list() for field in type.getFields()[1:]: tmp = "\t -- " + field.getDescription() + "\n" tmp += "\t" + field.getName() + " " if field.isNumeric(): if len(field) < 5: tmp += "smallint" else: tmp += "integer" else: tmp += "varchar(" + str(len(field)) + ")" if not field.isNullable(): tmp += " not null"