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

georgia-tech-db / eva / #844

31 Oct 2023 05:42AM UTC coverage: 0.0%. Remained the same
#844

push

circle-ci

Andy Xu
Fix typo

0 of 12389 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/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
×
16
import os
×
17
from contextlib import contextmanager
×
18

19
from evadb.executor.executor_utils import ExecutorError
×
20

21

22
def _get_database_handler(engine: str, **kwargs):
×
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:
×
30
        mod = dynamic_import(engine)
×
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":
×
38
        return mod.PostgresHandler(engine, **kwargs)
×
39
    elif engine == "sqlite":
×
40
        return mod.SQLiteHandler(engine, **kwargs)
×
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
×
56
def get_database_handler(engine: str, **kwargs):
×
57
    handler = _get_database_handler(engine, **kwargs)
×
58
    try:
×
59
        resp = handler.connect()
×
60
        if not resp.status:
×
61
            raise ExecutorError(f"Cannot establish connection due to {resp.error}")
62
        yield handler
×
63
    finally:
64
        handler.disconnect()
×
65

66

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