Interface through which the user may create, drop, alter or query underlying
        databases, tables, functions etc.

        :return: :class:`Catalog`
499306
def catalog(self):
        
        from pyspark.sql.catalog import Catalog
        if not hasattr(self, "_catalog"):
            self._catalog = Catalog(self)
        return self._catalog
854516
def newCatalog(sgml):
    
    ret = libxml2mod.xmlNewCatalog(sgml)
    if ret is None:raise treeError('xmlNewCatalog() failed')
    return catalog(_obj=ret)
550394
def db(self):
        
        if self.database is NotImplemented:
            self.database = Session

        return self.database
1301598
def query(self):
        
        queryWidget = self.queryWidget()
        
        # check to see if there is an active container for this widget
        container = queryWidget.containerFor(self)
        if container:
            return container.query()
        
        elif QueryCompound.typecheck(self._query):
            return self._query
        
        # generate a new query from the editor
        column = self.uiColumnDDL.currentSchemaPath()
        plugin = self.currentPlugin()
        editor = self.editor()
        op     = self.uiOperatorDDL.currentText()
        
        if column and plugin:
            query = Query(column)
            plugin.setupQuery(query, op, editor)
            return query
        else:
            return Query()
523549
def connect(url=None, schema=None, sql_path=None, multiprocessing=False):
    
    if url is None:
        url = os.environ.get("DATABASE_URL")
    return Database(url, schema, sql_path=sql_path, multiprocessing=multiprocessing)
63204
def main():
    
    args = command_line()

    # TODO: Decouple Book interface and implementation
    query = Book(
        title=args.title,
        author=args.author,
        max_results=args.max,
        language_code=args.language,
        fields=('title', 'authors', 'imageLinks', 'categories', 'description'),
    )

    if args.verbose:
        print('Request URL:')
        print(query.url)
        print(query.__dict__)

    # Temporary Display Interface
    books = query.json.get('items', None)
    if not books:
        raise AttributeError('Web Request Failed')

    for book in books:
        info = book['volumeInfo']

        # Retrieve ISBN/Reference Info
        if 'industryIdentifiers' in info:
            identifiers = dict([(ref['type'], ref['identifier']) for ref in info['industryIdentifiers']])

            # Prefer ISBN 13 over ISBN 10
            if 'ISBN_13' in identifiers:
                isbn_id, isbn = 'ISBN_13', identifiers['ISBN_13']
            else:
                isbn_id, isbn = identifiers.popitem()

        else:
            isbn_id, isbn = 'ISBN_##', 'N/A'

        # Format/Print
        display = 'Title: {title}\nAuthor: {authors}\n{isbn_id}: {isbn}\n'.format(
            title=info['title'],
            authors=', '.join(info.get('authors', ['N/A'])),
            isbn_id=isbn_id,
            isbn=isbn,
        )

        print(display)
1350343
def load_user_catalog():
    """"""
    cat_dir = user_data_dir()
    if not os.path.isdir(cat_dir):
        return Catalog()
    else:
        return YAMLFilesCatalog(cat_dir)
305218
def endpoint_catalog(catalog=None):  # noqa: E501
    
    if connexion.request.is_json:
        catalog = UserAuth.from_dict(connexion.request.get_json())  # noqa: E501

    if (not hasAccess()):
        return redirectUnauthorized()

    driver = LoadedDrivers.getDefaultDriver()
    auth = None
    if (catalog):
        auth = catalog
    return Response(status=200, body=driver.getCatalog(auth))
793288
def register_internal_data(cls):
    
    with app.app_context():
        if getattr(cls, 'endpoint', None) is None:
            orig_class = cls
            cls = type('Sandman' + cls.__name__, (cls, Model), {})
            cls.__from_class__ = orig_class
        current_app.class_references[cls.__tablename__] = cls
        current_app.class_references[cls.__name__] = cls
        current_app.class_references[cls.endpoint()] = cls
        if not getattr(cls, '__related_tables__', None):
            cls.__related_tables__ = set()
555654
def load_backend(**orm_config):
    
    settings = {}
    settings['SECRET_KEY'] = orm_config.get('secret_key', '')

    db_config = orm_config['database']
    if db_config:
        settings['DATABASES'] = {
            'default': database_settings(db_config)
        }

    from django_peeringdb.client_adaptor.setup import configure
    # Override defaults
    configure(**settings)
    # Must import implementation module after configure
    from django_peeringdb.client_adaptor import backend

    migrate = orm_config.get("migrate")
    if migrate and not backend.Backend().is_database_migrated():
        backend.Backend().migrate_database()

    return backend
1345046
def load_global_catalog():
    """"""
    cat_dir = global_data_dir()
    if not os.path.isdir(cat_dir):
        return Catalog()
    else:
        return YAMLFilesCatalog(cat_dir)
876816
def tear_down(self):
        
        # drop/delete the tables
        logger.info('resetting database...')
        BASE.metadata.drop_all(self.engine)
        return self
256617
def create(*catalog_roots)
      fs = [@db_filepath, @db_log_filepath, @config_filepath]
      fs.each do |f|
        FileUtils.rm(f) if File.exist?(f)
      end

      if File.exist? @config_filepath
        raise SimpleCatalogerError, "cannot create already existent catalog '#{@name}'"
      end
      @config = {
          :roots   => catalog_roots,
          :ignore  => %w{sub subtitles images},
          :version => DirCat::VERSION
      }
      write_config

      #
      # migrate db
      #
      # TODO: drop tables!
      ActiveRecord::Base.establish_connection(@active_record_config)
      ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : false
      migration_dir = File.join(File.dirname(__FILE__), %w{migration})
      unless Dir.exist? migration_dir
        raise "migration dir '#{migration_dir}' not exists"
      end
      ActiveRecord::Migrator.migrate(migration_dir, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
      require_models
    end
693272
def setup_catalog_mappings(portal):
    
    logger.info("*** Setup Catalog Mappings ***")

    at = api.get_tool("archetype_tool")
    for portal_type, catalogs in CATALOG_MAPPINGS:
        at.setCatalogsByType(portal_type, catalogs)
520904
def gui():
    """"""

    sel = psidialogs.multi_choice(libraries(),
                                  'select libraries to remove from %s!' % libraries_dir(),
                                  title='remove boards')
    print('%s selected' % sel)

    if sel:
        if psidialogs.ask_yes_no('Do you really want to remove selected libraries?\n' + '\n'.join(sel)):
            for x in sel:
                remove_lib(x)
                print('%s was removed' % x)
1236720
def make_query(catalog):
    
    query = {}
    request = api.get_request()
    index = get_search_index_for(catalog)
    limit = request.form.get("limit")

    q = request.form.get("q")
    if len(q) > 0:
        query[index] = q + "*"
    else:
        return None

    portal_type = request.form.get("portal_type")
    if portal_type:
        if not isinstance(portal_type, list):
            portal_type = [portal_type]
        query["portal_type"] = portal_type

    if limit and limit.isdigit():
        query["sort_limit"] = int(limit)

    return query
1359077
def db(self):
        

        # Initialize the database handle from the middleware's copy of
        # it
        if not self._db:
            self._db = self.middleware.db

        return self._db