예제 #1
0
파일: loader.py 프로젝트: WongTai/snippets
def parseDatum(input):
    rv=None

    if len(input) > 0:
        t=TigerTypes.getType(input[0])
        rv=t.parse(input)

    return rv
예제 #2
0
파일: loader.py 프로젝트: TaRiven/snippets
def parseDatum(input):
    rv = None

    if len(input) > 0:
        t = TigerTypes.getType(input[0])
        rv = t.parse(input)

    return rv
예제 #3
0
 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
예제 #4
0
파일: counter.py 프로젝트: WongTai/snippets
 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
예제 #5
0
파일: loader.py 프로젝트: WongTai/snippets
            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)
예제 #6
0
파일: loader.py 프로젝트: TaRiven/snippets
        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)
예제 #7
0
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"
예제 #8
0
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"