コード例 #1
0
    """
    This method will convert a filename to a tablename. Filenames are format 'all-*'. Tablename is in format 'w
    intel-'.

    :param filename:

    :return:
    """
    basename, _ = os.path.basename(filename).split(".")
    return basename.replace("all-", "wintel_")


cfg = my_env.init_env("bellavista", __file__)
logging.info("Start Application")
db = cfg['Main']['db']
ds = sqliteUtils(cfg)

windir = cfg['Main']['windir']
filelist = [
    file for file in os.listdir(windir) if file[0:len("all-")] == "all-"
]
for file in filelist:
    win_file = os.path.join(windir, file)
    table_name = get_tablename(win_file)
    logging.info("Converting file {fn} to table {tn}".format(fn=win_file,
                                                             tn=table_name))
    with open(win_file, newline='') as win_inv:
        # delimiter defaults to , - quotechar defaults to "
        win_reader = csv.DictReader(win_inv)
        loop = my_env.LoopInfo(table_name, 100)
        create_table_flag = True
コード例 #2
0
"""
This script will read the person and convert it to a Neo4J database.
"""

import logging
from lib import localstore
from lib import my_env
from lib.murcs import *
from lib.neostructure import *
from lib import neostore

cfg = my_env.init_env("bellavista", __file__)
logging.info("Start Application")
lcl = localstore.sqliteUtils(cfg)
ns = neostore.NeoStore(cfg)

sites = lcl.get_table("site")
region_d = {}
country_d = {}
site_node_d = {}
my_loop = my_env.LoopInfo("Sites", 20)
for site in sites:
    row = dict(site)
    # Get site links
    region = row.pop("region")
    if region:
        region_d[row["siteId"]] = region
    country = row.pop("country")
    if country:
        country_d[row["siteId"]] = country
    # Site link information is handled and removed from row, now handle remaining columns
コード例 #3
0
ファイル: rebuild_sqlite.py プロジェクト: dirkhpe/bvtools
"""
This procedure will rebuild the sqlite BellaVista database
"""

import logging
from lib import my_env
from lib import localstore

cfg = my_env.init_env("bellavista", __file__)
logging.info("Start application")
bv = localstore.sqliteUtils()
bv.rebuild()
logging.info("sqlite bellavista rebuild")
logging.info("End application")