# Path: orm.py
# def now():
# def set_sqlite_pragma(dbapi_connection, connection_record):
#     def is_blank(self):
#     def save(self):
#     def save(self):
#     def save(self):
# def counter():
# def exithandler():
# class Value(Base):
# class DataSet(Base):
# class Indicator(Base):


import re
import datetime
import requests
import orm
from orm import session, Value, DataSet, Indicator
	        yield {"dsID": dsID,
                       "region": country['country'],
		       "period": int(key[1:]),
		       "value": float(country[key]),
                       "indID": lookup[socrata_id],
                       "source": data_url.format(socrata_id),
                       "is_number": True}

def get_rank(socrata_id):
    url = data_url.format(socrata_id)
    countries = requests.get(url).json()
    return parse_rank(socrata_id, countries)
    

def parse_rank(socrata_id, countries):
    for country in countries:
        if 'hdi_rank' in country:
	    yield {"dsID": dsID,
		   "region": country['country'],
		   "period": 2012,  # TODO
		   "value": int(country['hdi_rank']),
		   "indID": "PSE220",
		   "source": data_url.format(socrata_id),
		   "is_number": True}
		   
                           
DataSet(**dataset).save()
maxdate=None
for socrata_code in lookup:
    ind = get_metadata(socrata_code)

# Path: orm.py
# def now():
# def set_sqlite_pragma(dbapi_connection, connection_record):
#     def is_blank(self):
#     def save(self):
#     def save(self):
#     def save(self):
# def counter():
# def exithandler():
# class Value(Base):
# class DataSet(Base):
# class Indicator(Base):


# Path: hdr_new.py
import re
import datetime
import requests
import orm
from orm import session, Value, DataSet, Indicator

	        yield {"dsID": dsID,
                       "region": country['country'],
		       "period": int(key[1:]),
		       "value": float(country[key]),
                       "indID": lookup[socrata_id],
                       "source": data_url.format(socrata_id),
                       "is_number": True}

def get_rank(socrata_id):
    url = data_url.format(socrata_id)
    countries = requests.get(url).json()
    return parse_rank(socrata_id, countries)
    

def parse_rank(socrata_id, countries):
    for country in countries:
        if 'hdi_rank' in country:
	    yield {"dsID": dsID,
		   "region": country['country'],
		   "period": 2012,  # TODO
		   "value": int(country['hdi_rank']),
		   "indID": "PSE220",
		   "source": data_url.format(socrata_id),
		   "is_number": True}
		   
                           
DataSet(**dataset).save()
maxdate=None
for socrata_code in lookup:
    ind = get_metadata(socrata_code)

    Indicator(**ind).save()