Пример #1
0
 def db_connect(cls):
     settings = Config.get('database')
     cls._db = web.database(dbn=settings['dbn'],
                            user=settings['user'],
                            pw=settings['password'],
                            db=settings['db'],
                            host=settings['host'])
     log.info("Connected to db: %s" % cls._db)
Пример #2
0
def sessionDB():
    """
    Gets the session database object.  Database object is based from
    web.py's database handling.  This utilizes values found in the
    config.yaml file.
    """
    config = Config.get('database')
    return web.database(dbn=config['dbn'], user=config['user'], pw=config['password'], db=config['db'], host=config['host'])
Пример #3
0
def sessionDB():
    """
    Gets the session database object.  Database object is based from
    web.py's database handling.  This utilizes values found in the
    config.yaml file.
    """
    config = Config.get('database')
    return web.database(dbn=config['dbn'], user=config['user'], pw=config['password'], db=config['db'], host=config['host'])
Пример #4
0
import lib.web as web
import datetime

db = web.database(dbn='sqlite', db='anorak.db')

def get_animes():
    return db.select('animes', order='title ASC')
    
def get_anime(id):
    try:
        return db.select('animes', where='id=$id', vars=locals())[0]
    except IndexError:
        return None
        
def get_anime_by_title(title):
    # Custom query to make sure the where is case-insensitive
    try:
        return db.query("SELECT * FROM animes WHERE LOWER(title)=LOWER(\'%s\')" % title)[0]
    except IndexError:
        # Don't give up, try the alternative title
        try:
            return db.query("SELECT * FROM animes WHERE LOWER(alternativeTitle)=LOWER(\'%s\')" % title)[0]
        except IndexError:
            return None

def new_anime(id, title, subber, location, quality=0):
    db.insert('animes', id=id, title=title, subber=subber, location=location, quality=quality)
    
def remove_anime(id):
    db.delete('animes', where='id=$id', vars=locals())
    db.delete('episodes', where='id=$id', vars=locals())
Пример #5
0
 def connectDB(self, dbParams):
     self.DBHandle = web.database(dbn=dbParams.get('dbn'),user=dbParams.get('user'), pw=dbParams.get('password'), db=dbParams.get('db'), host=dbParams.get('host'))
Пример #6
0
 def db_connect(cls):
     settings = Config.get('database')
     cls._db = web.database(dbn=settings['dbn'], user=settings['user'], pw=settings['password'], db=settings['db'], host=settings['host'])
     log.info("Connected to db: %s" % cls._db)
Пример #7
0
 def connectDB(self, dbParams):
     self.DBHandle = web.database(dbn=dbParams.get('dbn'),
                                  user=dbParams.get('user'),
                                  pw=dbParams.get('password'),
                                  db=dbParams.get('db'),
                                  host=dbParams.get('host'))
Пример #8
0
import lib.web as web
import datetime

db = web.database(dbn='sqlite', db='anorak.db')


def get_animes():
    return db.select('animes', order='title ASC')


def get_anime(id):
    try:
        return db.select('animes', where='id=$id', vars=locals())[0]
    except IndexError:
        return None


def get_anime_by_title(title):
    # Custom query to make sure the where is case-insensitive
    try:
        return db.query(
            "SELECT * FROM animes WHERE LOWER(title)=LOWER(\'%s\')" % title)[0]
    except IndexError:
        # Don't give up, try the alternative title
        try:
            return db.query(
                "SELECT * FROM animes WHERE LOWER(alternativeTitle)=LOWER(\'%s\')"
                % title)[0]
        except IndexError:
            # Don't give up, try the official title
            try: