Exemple #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)
Exemple #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)
    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)
Exemple #4
0
                        'templates')
app = Flask(__name__, template_folder=tmpl_dir)

# XXX: The Database URI should be in the format of:
#
#     postgresql://USER:PASSWORD@<IP_OF_POSTGRE_SQL_SERVER>/<DB_NAME>
#
# For example, if you had username ewu2493, password foobar, then the following line would be:
#
#     DATABASEURI = "postgresql://*****:*****@<IP_OF_POSTGRE_SQL_SERVER>/postgres"
#
# For your convenience, we already set it to the class database

# Use the DB credentials you received by e-mail
DB_USER = credentials.get_db_user()
DB_PASSWORD = credentials.get_db_password()

DB_SERVER = "w4111.cisxo09blonu.us-east-1.rds.amazonaws.com"

DATABASEURI = "postgresql://" + DB_USER + ":" + DB_PASSWORD + "@" + DB_SERVER + "/w4111"

#
# This line creates a database engine that knows how to connect to the URI above
#
engine = create_engine(DATABASEURI)

# Here we create a test table and insert some values in it
engine.execute("""DROP TABLE IF EXISTS test;""")
engine.execute("""CREATE TABLE IF NOT EXISTS test (
  id serial,
  name text
Exemple #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)
Exemple #6
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)