示例#1
0
文件: mysql.py 项目: jof/weewx
def drop(host='localhost',
         user='',
         password='',
         database_name='',
         driver='',
         port=3306,
         engine=DEFAULT_ENGINE,
         **kwargs):
    """Drop (delete) the specified database."""
    # Open up a connection
    try:
        connect = MySQLdb.connect(host=host,
                                  user=user,
                                  passwd=password,
                                  port=int(port),
                                  **kwargs)
        cursor = connect.cursor()
        try:
            cursor.execute("DROP DATABASE %s" % database_name)
        except _mysql_exceptions.OperationalError:
            raise weedb.NoDatabase(
                """Attempt to drop non-existent database %s""" %
                (database_name, ))
        finally:
            cursor.close()
    except _mysql_exceptions.OperationalError, e:
        raise weedb.OperationalError(e)
示例#2
0
文件: sqlite.py 项目: yhyuan/weewx
def drop(database_name='', SQLITE_ROOT='', driver='', **argv):
    file_path = get_filepath(SQLITE_ROOT, database_name, **argv)
    try:
        os.remove(file_path)
    except OSError:
        raise weedb.NoDatabase("""Attempt to drop non-existent database %s""" %
                               (file_path, ))
示例#3
0
def drop(database_name='', root='', driver='', **argv):
    file_path = os.path.join(root, database_name)
    try:
        os.remove(file_path)
    except OSError:
        raise weedb.NoDatabase("""Attempt to drop non-existent database %s""" %
                               (file_path, ))