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

georgia-tech-db / eva / d8e82e0e-8b3d-4d22-9a86-fe9f65c8b264

28 Oct 2023 10:50PM UTC coverage: 67.392% (-9.6%) from 76.956%
d8e82e0e-8b3d-4d22-9a86-fe9f65c8b264

push

circle-ci

xzdandy
Use table for side by side display

8763 of 13003 relevant lines covered (67.39%)

0.67 hits per line

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

65.63
/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✔
38
        return mod.PostgresHandler(engine, **kwargs)
×
39
    elif engine == "sqlite":
1✔
40
        return mod.SQLiteHandler(engine, **kwargs)
1✔
41
    elif engine == "mysql":
×
42
        return mod.MysqlHandler(engine, **kwargs)
×
43
    elif engine == "mariadb":
×
44
        return mod.MariaDbHandler(engine, **kwargs)
×
45
    elif engine == "clickhouse":
×
46
        return mod.ClickHouseHandler(engine, **kwargs)
×
47
    elif engine == "snowflake":
×
48
        return mod.SnowFlakeDbHandler(engine, **kwargs)
×
49
    elif engine == "github":
×
50
        return mod.GithubHandler(engine, **kwargs)
×
51
    else:
52
        raise NotImplementedError(f"Engine {engine} is not supported")
53

54

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

66

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