Exemplo n.º 1
0
def __check_db():
    db = SqLite()

    ns = config.CHOSEN_FEATURE_TABLE
    if not db.hasNamespace(ns):
        print ns + " namespace doesn't exist! Creating it..."
        song_def = {
            commonHash: "TEXT",
            commonTitle: "TEXT",
            commonArtist: "TEXT",
            commonPath: "TEXT"
        }

        if ns == config.DEFAULT_SONG_TABLE:
            from input.data_mining import attribute_schema
        else:
            from input.marsyas_mir import attribute_schema

        for attribute in attribute_schema:
            song_def[attribute.name] = attribute.type

        db.installNamespace(ns, song_def)
        print ns + " namespace created\n"

    #Mood namespace
    if not db.hasNamespace(moodNamespace):
        print "Mood namespace doesn't exist! Creating it..."

        mood_def = {commonHash: "TEXT", moodTitle: "TEXT"}
        db.installNamespace(moodNamespace, mood_def)
        print "Mood namespace created\n"
Exemplo n.º 2
0
def __check_db():
    db = SqLite();

    ns = config.CHOSEN_FEATURE_TABLE
    if not db.hasNamespace(ns):
        print ns + " namespace doesn't exist! Creating it..."
        song_def = {
            commonHash:"TEXT",
            commonTitle:"TEXT",
            commonArtist:"TEXT",
            commonPath:"TEXT"
        }

        if ns == config.DEFAULT_SONG_TABLE:
            from input.data_mining import attribute_schema
        else:
            from input.marsyas_mir import attribute_schema

        for attribute in attribute_schema:
            song_def[attribute.name] = attribute.type

        db.installNamespace(ns, song_def)
        print ns + " namespace created\n"

    #Mood namespace
    if not db.hasNamespace(moodNamespace):
        print "Mood namespace doesn't exist! Creating it..."

        mood_def = {
            commonHash:"TEXT",
            moodTitle:"TEXT"
        }
        db.installNamespace(moodNamespace, mood_def)
        print "Mood namespace created\n"
Exemplo n.º 3
0
#
# These are the tests for the SqLite module. they will test the basic
# functionality.
# I didn't use any test suits because I didn't know any libraries in python
# and I didn't have enough time.

from sys import path

# add the lib to path
#path.append("../../")

from data.SqLite import *

print("Starting tests, things should run without errors")
sq1 = SqLite("test")
sq1.setNamespace("test1")

if sq1.hasNamespace():
    sq1.removeNamespace()
    print("Removed old test database.")

table_def = {"field1":"TEXT", "field2":"INTEGER", "field3":"BLOB"}

print("Installing namespace")
sq1.installNamespace("test1", table_def)

if not sq1.hasNamespace():
    print("ERROR: was not able to create database")
    
sq1.write({"field1":"Test Value 1", "field2":100, "field3":"something"})