Ejemplo n.º 1
0
def setup_module():
    global transaction, connection, engine, session
    settings.TESTING["running"] = True
    db_helper.create_db()
    engine = db_helper.make_engine(section="test")
    connection = engine.connect()
    transaction = connection.begin()
    session = db_helper.set_session(engine)
    session.execute("CREATE EXTENSION IF NOT EXISTS postgis;")
    session.commit()
    models.Base.metadata.drop_all(bind=engine)
    models.Base.metadata.create_all(bind=engine)
Ejemplo n.º 2
0
def main():
    try:
        db_helper.create_db()

        list_url = "http://www.ygdy8.net/html/gndy/dyzz/list_23_2.html"
        req = urllib.request.urlopen(list_url)
        resp = req.read()
        print(req)

        resp_data = resp.decode('gbk', errors="ignore")
        result_list = fetch_list(resp_data)
        for item in result_list:
            detail = fetch_detail(item)
            print(item)
            db_helper.save(detail)
            print(detail)
    except UnicodeDecodeError as e:
        print('d', type(resp))
        print(e)