• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

georgia-tech-db / eva / #758

04 Sep 2023 08:37PM UTC coverage: 0.0% (-78.3%) from 78.333%
#758

push

circle-ci

hershd23
Increased underline length in at line 75 in text_summarization.rst
	modified:   docs/source/benchmarks/text_summarization.rst

0 of 11303 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/evadb/catalog/services/database_catalog_service.py
1
# coding=utf-8
2
# Copyright 2018-2023 EvaDB
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15

16
from sqlalchemy.orm import Session
×
17
from sqlalchemy.sql.expression import select
×
18

19
from evadb.catalog.models.database_catalog import DatabaseCatalog
×
20
from evadb.catalog.models.utils import DatabaseCatalogEntry
×
21
from evadb.catalog.services.base_service import BaseService
×
22
from evadb.utils.errors import CatalogError
×
23
from evadb.utils.logging_manager import logger
×
24

25

26
class DatabaseCatalogService(BaseService):
×
27
    def __init__(self, db_session: Session):
×
28
        super().__init__(DatabaseCatalog, db_session)
×
29

30
    def insert_entry(
×
31
        self,
32
        name: str,
33
        engine: str,
34
        params: dict,
35
    ):
36
        try:
×
37
            db_catalog_obj = self.model(
×
38
                name=name,
39
                engine=engine,
40
                params=params,
41
            )
42
            db_catalog_obj = db_catalog_obj.save(self.session)
×
43

44
        except Exception as e:
45
            logger.exception(
46
                f"Failed to insert entry into database catalog with exception {str(e)}"
47
            )
48
            raise CatalogError(e)
49

50
    def get_entry_by_name(self, database_name: str) -> DatabaseCatalogEntry:
×
51
        """
52
        Get the table catalog entry with given table name.
53
        Arguments:
54
            database_name  (str): Database name
55
        Returns:
56
            DatabaseCatalogEntry - catalog entry for given database name
57
        """
58
        entry = self.session.execute(
×
59
            select(self.model).filter(self.model._name == database_name)
60
        ).scalar_one_or_none()
61
        if entry:
×
62
            return entry.as_dataclass()
×
63
        return entry
×
64

65
    def delete_entry(self, database_entry: DatabaseCatalogEntry):
×
66
        """Delete database from the catalog
67
        Arguments:
68
            database  (DatabaseCatalogEntry): database to delete
69
        Returns:
70
            True if successfully removed else false
71
        """
72
        try:
×
73
            db_catalog_obj = self.session.execute(
×
74
                select(self.model).filter(self.model._row_id == database_entry.row_id)
75
            ).scalar_one_or_none()
76
            db_catalog_obj.delete(self.session)
×
77
            return True
×
78
        except Exception as e:
79
            err_msg = (
80
                f"Delete database failed for {database_entry} with error {str(e)}."
81
            )
82
            logger.exception(err_msg)
83
            raise CatalogError(err_msg)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc