Ejemplo n.º 1
0
 def show_equipment(self):
     """
     This page show all equipments
     """
     db = DB("../DB/DB.db")
     items = db.read_equipment()
     tmpl = lookup.get_template("result_equipment.html")
     return tmpl.render(array=items)
Ejemplo n.º 2
0
 def show_activity(self):
     """
     This page show all activities
     """
     db = DB("../DB/DB.db")
     items = db.read_activity()
     tmpl = lookup.get_template("result_activity.html")
     return tmpl.render(array=items)
Ejemplo n.º 3
0
 def show_installation(self):
     """
     This page show all installations
     """
     db = DB("../DB/DB.db")
     items = db.read_installation()
     tmpl = lookup.get_template("result_installation.html")
     return tmpl.render(array=items, table="Installation")
Ejemplo n.º 4
0
 def index(self):
     """
     The index page : introduce the website, show different links to navigate
     on the website and show a random installation
     KNOWN BUGS : Activity are never found
     """
     db = DB("../DB/DB.db")
     array = db.attribute_installation_to_array("install_num")
     random.seed()
     rand_tuples = db.select_all_from_install_pk(array[random.randint(0, len(array)-1)][0])
     tmpl = lookup.get_template("index.html")
     return tmpl.render(installation=rand_tuples)
Ejemplo n.º 5
0
 def test_should_return_a_train_station(self):
     database = Database()
     self.assertEqual(type(database.client), MongoClient)
     self.assertEqual(type(database.db), db_mongo.Database)
     self.assertEqual(type(database.train_station_collection),
                      collection.Collection)
     self.assertIsNotNone(database.train_station_collection)
Ejemplo n.º 6
0
def create_table(table_name, db_path):
    """
    This fonction is used to create one of the table (Installation/Equipment/Activity) in the database.
    It needs the table name and the database path.
    """
    db = DB(db_path)
    if table_name == "Installation":
        db.creation_table_installation()
    elif table_name == "Equipment":
        db.creation_table_equipment()
    elif table_name == "Activity":
        db.creation_table_activity()
    db.disconnect(True)
Ejemplo n.º 7
0
def insertion_json_file(table_name, db_path, json_file):
    """
    This function is used to unserialize a json file and to insert the content into a table
    It needs the table name, the database path and the json path
    """
    db = DB(db_path)
    progress = ProgressBar()
    s = Seri()
    if table_name == "Installation":
        s.unserialize_json_installation(json_file)
        for item in progress(s.collection):
            db.insertion_installation(item)
    elif table_name == "Equipment":
        s.unserialize_json_equipment(json_file)
        for item in progress(s.collection):
            db.insertion_equipment(item)
    elif table_name == "Activity":
        s.unserialize_json_activity(json_file)
        for item in progress(s.collection):
            db.insertion_activity(item)
    db.disconnect(True)
Ejemplo n.º 8
0
def read_database(table_name, db_path):
    """
    This function is used to display all elements in a table
    It needs the table name and the path to the database
    """
    db = DB(db_path)
    if table_name == "Installation":
        res = db.read_installation()
        print(res)
    elif table_name == "Equipment":
        res = db.read_equipment()
        print(res)
    elif table_name == "Activity":
        res = db.read_activity()
        print(res)
    db.disconnect(True)
Ejemplo n.º 9
0
def get_all_train_stations_this_big(howbig):
    return Database().train_station_collection.find({"howbig": howbig})
Ejemplo n.º 10
0
def get_all_train_stations():
    return Database().train_station_collection.find()
Ejemplo n.º 11
0
 def __init__(self):
     self._database = Database.instance()
     self._unigram_regex = re.compile(r"([а-яА-Яa-zA-Z]+)")
Ejemplo n.º 12
0
# coding: utf-8

# In[12]:

#!/usr/bin/env python
# coding: utf-8

# In[5]:
import sys
sys.path.append('..')
from dao.database import Database
import dao.config as config
import pandas as pd

# DB 연결
db = Database(config)


# 아이템, 유저 가져오기
def get_cfsource():
    sql = "SELECT cust_id, stu_id, score "
    sql += "FROM review"
    result = db.run_query(sql)
    df = pd.DataFrame(result)
    return df


# 메인 추천 업체 가져오기
def get_reco_studio(studio_list):
    result_list = []
    for stu_id in studio_list: