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

georgia-tech-db / eva / #840

18 Oct 2023 09:51PM UTC coverage: 68.616% (-9.8%) from 78.391%
#840

push

circle-ci

jiashenC
[BUMP]: v0.3.9+dev

2 of 2 new or added lines in 1 file covered. (100.0%)

8634 of 12583 relevant lines covered (68.62%)

0.69 hits per line

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

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

52

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

64

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