Ejemplo n.º 1
0
    print >>sys.stderr, "error: %s" % (e)
    sys.exit(1)

# Start ORM classes up, and get a connection to the DB.
Base.metadata.create_all(engine)
session = DBSession()

# Create a table of id-to-Person based on the contents of the people file.
people_rec = {}
for i, name in people[1:]:
    i = int(i)

    p = Person(id=i, name=name.decode("utf-8"))

    people_rec[i] = p
    session.add(p)

# Construct an Episode for each record in the episode file, and add it to the
# databse.
for i, season, ep, title, airdate, teleplay, story, director, stardate, url in episodes[1:]:
    # Extract the fields that exist more or less as is.
    i = int(i)
    season = int(season)
    ep = int(ep)

    # Parse the (American-style) dates from the airdate field, creating a Python
    # datetime object.
    month, day, year = airdate.split("/")
    month = "%02d" % (int(month))
    day = "%02d" % (int(day))
    airdate = datetime.datetime.strptime("%s/%s/%s" % (month, day, year), "%m/%d/%Y")
Ejemplo n.º 2
0
    print >> sys.stderr, "error: %s" % (e)
    sys.exit(1)

# Start ORM classes up, and get a connection to the DB.
Base.metadata.create_all(engine)
session = DBSession()

# Create a table of id-to-Person based on the contents of the people file.
people_rec = {}
for i, name in people[1:]:
    i = int(i)

    p = Person(id=i, name=name.decode("utf-8"))

    people_rec[i] = p
    session.add(p)

# Construct an Episode for each record in the episode file, and add it to the
# databse.
for i, season, ep, title, airdate, teleplay, story, director, stardate, url in episodes[
        1:]:
    # Extract the fields that exist more or less as is.
    i = int(i)
    season = int(season)
    ep = int(ep)

    # Parse the (American-style) dates from the airdate field, creating a Python
    # datetime object.
    month, day, year = airdate.split("/")
    month = "%02d" % (int(month))
    day = "%02d" % (int(day))