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

georgia-tech-db / eva / 20a9a0f9-edcc-437c-815d-bcc1a2d22b17

10 Nov 2023 04:50AM UTC coverage: 66.644% (-10.2%) from 76.812%
20a9a0f9-edcc-437c-815d-bcc1a2d22b17

push

circleci

americast
update docs

0 of 1 new or added line in 1 file covered. (0.0%)

1354 existing lines in 113 files now uncovered.

8767 of 13155 relevant lines covered (66.64%)

0.67 hits per line

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

61.76
/evadb/third_party/databases/interface.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
import importlib
1✔
16
import os
1✔
17
from contextlib import contextmanager
1✔
18

19
from evadb.executor.executor_utils import ExecutorError
1✔
20

21

22
def _get_database_handler(engine: str, **kwargs):
1✔
23
    """
24
    Return the database handler. User should modify this function for
25
    their new integrated handlers.
26
    """
27

28
    # Dynamically import the top module.
29
    try:
1✔
30
        mod = dynamic_import(engine)
1✔
31
    except ImportError:
32
        req_file = os.path.join(os.path.dirname(__file__), engine, "requirements.txt")
33
        if os.path.isfile(req_file):
34
            with open(req_file) as f:
35
                raise ImportError(f"Please install the following packages {f.read()}")
36

37
    if engine == "postgres":
1✔
UNCOV
38
        return mod.PostgresHandler(engine, **kwargs)
×
39
    elif engine == "sqlite":
1✔
40
        return mod.SQLiteHandler(engine, **kwargs)
1✔
UNCOV
41
    elif engine == "mysql":
×
UNCOV
42
        return mod.MysqlHandler(engine, **kwargs)
×
UNCOV
43
    elif engine == "mariadb":
×
UNCOV
44
        return mod.MariaDbHandler(engine, **kwargs)
×
UNCOV
45
    elif engine == "clickhouse":
×
UNCOV
46
        return mod.ClickHouseHandler(engine, **kwargs)
×
UNCOV
47
    elif engine == "snowflake":
×
UNCOV
48
        return mod.SnowFlakeDbHandler(engine, **kwargs)
×
49
    elif engine == "github":
×
50
        return mod.GithubHandler(engine, **kwargs)
×
51
    elif engine == "slack":
×
52
        return mod.SlackHandler(engine, **kwargs)
×
53
    else:
54
        raise NotImplementedError(f"Engine {engine} is not supported")
55

56

57
@contextmanager
1✔
58
def get_database_handler(engine: str, **kwargs):
1✔
59
    handler = _get_database_handler(engine, **kwargs)
1✔
60
    try:
1✔
61
        resp = handler.connect()
1✔
62
        if not resp.status:
1✔
63
            raise ExecutorError(f"Cannot establish connection due to {resp.error}")
64
        yield handler
1✔
65
    finally:
66
        handler.disconnect()
1✔
67

68

69
def dynamic_import(handler_dir):
1✔
70
    import_path = f"evadb.third_party.databases.{handler_dir}.{handler_dir}_handler"
1✔
71
    return importlib.import_module(import_path)
1✔
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

© 2026 Coveralls, Inc