예제 #1
0
파일: musicsqlcmd.py 프로젝트: gy/musicsql
def add_feature():
    usage = """
usage: musicsqlcmd.py add module --database database [--password] [--backend dbtype]

::  adds a new node property to the database using a module.
"""
    options, args = getOptions(longOptions, usage)
    if not args:
        sys.exit(usage)
    import musicsql.database as msql

    module = msql.load_submodule(args[0])
    options["tablename"] = args[0]
    query = module.Query(**options)
    try:
        query.run()
    except KeyboardInterrupt:
        pass
예제 #2
0
파일: musicsqlcmd.py 프로젝트: gy/musicsql
def list_modules():
    import musicsql.database as msql

    print "\n:: Modules can be invoked with the 'add' function to add additional properties to nodes."
    options, args = getOptions()

    modules = msql.list_submodules().keys()
    modules.sort()
    hubs = {}
    for property in modules:
        module = msql.load_submodule(property)
        instance = module.Query(**options)
        instance.table_data()
        key = instance.foreignkey[1]
        if not hubs.has_key(key):
            hubs[key] = []
        hubs[key].append(property)
    for hub, modules in hubs.items():
        print "\nAvailable modules for '%s':" % hub
        modules.sort()
        for module in modules:
            print "  %s" % module