Exemple #1
0
def go():
    records = medians.load()

    for record in records:
        # medians correspond to offerings
        print record

        # Course
        c, created = Course.objects.get_or_create(dept=record['dept'],
                                                  number=record['number'])
        if created:
            c.dept = record['dept']
            c.number = record['number']
            c.save()

        # Course offering
        o, created = CourseOffering.objects.get_or_create(
            course=c, term=record['term'], section=record['section'])

        o.median = record['median']
        if created:
            o.term = record['term']
            o.section = record['section']
            o.enrollment = record['enrollment']
            o.course = c

        o.save()
Exemple #2
0
def populate_medians(request):
    import medians
    records = medians.load()

    for record in records:
        # medians correspond to offerings

        # Course
        c = Course.objects.get_or_create(dept=record['dept'],
                                         number=record['number'])
        c.dept = record['dept']
        c.number = record['number']
        c.put()

        # Course offering
        o = CourseOffering.objects.get_or_create(course=c,
                                                 term=record['term'],
                                                 section=record['section'])

        o.median = record['median']
        o.term = record['term']
        o.section = record['section']
        o.enrollment = record['enrollment']

        o.course = c
        o.put()
def go():
    records = medians.load()

    for record in records:
        # medians correspond to offerings
        print record

        # Course
        c,created = Course.objects.get_or_create(dept=record['dept'], number=record['number'])
        if created:
            c.dept = record['dept']
            c.number = record['number']
            c.save()

        # Course offering
        o,created = CourseOffering.objects.get_or_create(course=c, term=record['term'], section=record['section'])

        o.median = record['median']
        if created:
            o.term = record['term']
            o.section = record['section']
            o.enrollment = record['enrollment']
            o.course = c

        o.save()
Exemple #4
0
def populate_medians(request):
    import medians
    records = medians.load()

    for record in records:
        # medians correspond to offerings

        # Course
        c = Course.objects.get_or_create(dept=record['dept'], number=record['number'])
        c.dept = record['dept']
        c.number = record['number']
        c.put()

        # Course offering
        o = CourseOffering.objects.get_or_create(course=c, term=record['term'], section=record['section'])

        o.median = record['median']
        o.term = record['term']
        o.section = record['section']
        o.enrollment = record['enrollment']

        o.course = c
        o.put()
#!/usr/bin/env python
#
# Imports median json information to database
#

import couchdb
import medians
import sys

records = medians.load()

# Create database
couch = couchdb.Server()

if 'medians' in couch:
    del couch['medians']
db = couch.create('medians')

# Populate with a document per record
print 'Populating', len(records), 'median records...'
db.update(records)
#!/usr/bin/env python
# 
# Imports median json information to database
#

import couchdb
import medians
import sys

records = medians.load()

# Create database
couch = couchdb.Server()

if 'medians' in couch:
    del couch['medians']
db = couch.create('medians')

# Populate with a document per record
print 'Populating',len(records),'median records...'
db.update(records)