예제 #1
0
    def __init__(self, arguments):

        # Configure Session class with desired options
        Session = sessionmaker()

        # Import credentials
        db_name = credentials.get_db_name()
        db_user_name = credentials.get_db_user_name()
        db_host = credentials.get_db_host()
        db_password = credentials.get_db_password()
        db_backend = credentials.get_db_backend()

        # Later, we create the engine
        engine = create_engine('{backend}://{user}:{password}@{host}/{name}?charset=utf8'
                                .format(backend=db_backend,
                                        user=db_user_name,
                                        password=db_password,
                                        host=db_host,
                                        name=db_name),
                                        # echo=True
                                        )

        # Associate it with our custom Session class
        Session.configure(bind=engine)

        # API Credentials
        API_KEY = credentials.get_lastfm_api_key()
        API_SECRET = credentials.get_lastfm_api_secret()
        DB_NAME = credentials.get_db_name()

        network = pylast.LastFMNetwork(api_key=API_KEY,
                                       api_secret=API_SECRET,)

        variables = Variables(arguments, Session, network)

        #TODO: evaluate listdir for artists_dir lazily
        for artist in os.listdir(variables.dirs.artists):
            print '[+]>>>> Adding ' + artist
            self.add_band(variables, artist)
예제 #2
0
    def __init__(self, arguments):

        # Configure Session class with desired options
        Session = sessionmaker()

        # Import credentials
        db_name = credentials.get_db_name()
        db_user_name = credentials.get_db_user_name()
        db_host = credentials.get_db_host()
        db_password = credentials.get_db_password()
        db_backend = credentials.get_db_backend()

        # Later, we create the engine
        engine = create_engine(
            '{backend}://{user}:{password}@{host}/{name}?charset=utf8'.format(
                backend=db_backend,
                user=db_user_name,
                password=db_password,
                host=db_host,
                name=db_name),
            # echo=True
        )

        # Associate it with our custom Session class
        Session.configure(bind=engine)

        # API Credentials
        API_KEY = credentials.get_lastfm_api_key()
        API_SECRET = credentials.get_lastfm_api_secret()
        DB_NAME = credentials.get_db_name()

        network = pylast.LastFMNetwork(
            api_key=API_KEY,
            api_secret=API_SECRET,
        )

        variables = Variables(arguments, Session, network)

        self.download_missing_images(variables)
예제 #3
0
    def __init__(self, arguments):

        # Configure Session class with desired options
        Session = sessionmaker()

        # Import credentials
        db_name = credentials.get_db_name()
        db_user_name = credentials.get_db_user_name()
        db_host = credentials.get_db_host()
        db_password = credentials.get_db_password()
        db_backend = credentials.get_db_backend()

        # Later, we create the engine
        engine = create_engine('{backend}://{user}:{password}@{host}/{name}?charset=utf8'
                                .format(backend=db_backend,
                                        user=db_user_name,
                                        password=db_password,
                                        host=db_host,
                                        name=db_name),
                                        # echo=True
                                        )

        # Associate it with our custom Session class
        Session.configure(bind=engine)

        # API Credentials
        API_KEY = credentials.get_lastfm_api_key()
        API_SECRET = credentials.get_lastfm_api_secret()
        DB_NAME = credentials.get_db_name()

        network = pylast.LastFMNetwork(api_key=API_KEY,
                                       api_secret=API_SECRET,)

        variables = Variables(arguments, Session, network)

        self.download_missing_images(variables)
예제 #4
0
from schema import Base
from sqlalchemy import create_engine
from sqlalchemy_utils import database_exists, create_database, drop_database
import credentials

db_name = credentials.get_db_name()
db_user_name = credentials.get_db_user_name()
db_host = credentials.get_db_host()
db_password = credentials.get_db_password()
db_backend = credentials.get_db_backend()

# later, we create the engine
engine = create_engine('{backend}://{user}:{password}@{host}/{name}'.format(
    backend=db_backend,
    user=db_user_name,
    password=db_password,
    host=db_host,
    name=db_name))

if __name__ == '__main__':
    # create db if it doesn't exist
    if database_exists(engine.url):
        print 'Database already exists.'
        exit()
    try:
        create_database(engine.url)
        Base.metadata.create_all(engine)
        print "Database created."
    except Exception as e:
        print str(e)
예제 #5
0
from schema import Base
from sqlalchemy import create_engine
from sqlalchemy_utils import database_exists, create_database, drop_database
import credentials

db_name = credentials.get_db_name()
db_user_name = credentials.get_db_user_name()
db_host = credentials.get_db_host()
db_password = credentials.get_db_password()
db_backend = credentials.get_db_backend()

# later, we create the engine
engine = create_engine('{backend}://{user}:{password}@{host}/{name}'.format(backend=db_backend,
                                                                            user=db_user_name,
                                                                             password=db_password,
                                                                             host=db_host,
                                                                             name=db_name))


if __name__ == '__main__':
    # create db if it doesn't exist
    if database_exists(engine.url):
        print 'Database already exists.'
        exit()
    try:
        create_database(engine.url)
        Base.metadata.create_all(engine)
        print "Database created."
    except Exception as e:
        print str(e)