コード例 #1
0
def connect(
    uri: Optional[str] = None,
    user: Optional[str] = None,
    password: Optional[str] = None,
    host: Optional[str] = None,
    port: Optional[int] = 6274,
    database: Optional[str] = None,
    protocol: str = 'binary',
    session_id: Optional[str] = None,
    ipc: Optional[bool] = None,
    gpu_device: Optional[int] = None,
):
    """Create a client for OmniSciDB backend.

    Parameters
    ----------
    uri : str, optional
    user : str, optional
    password : str, optional
    host : str, optional
    port : int, default 6274
    database : str, optional
    protocol : {'binary', 'http', 'https'}, default 'binary'
    session_id: str, optional
    ipc : bool, optional
      Enable Inter Process Communication (IPC) execution type.
      `ipc` default value is False when `gpu_device` is None, otherwise
      its default value is True.
    gpu_device : int, optional
      GPU Device ID.

    Returns
    -------
    OmniSciDBClient
    """
    client = OmniSciDBClient(
        uri=uri,
        user=user,
        password=password,
        host=host,
        port=port,
        database=database,
        protocol=protocol,
        session_id=session_id,
        ipc=ipc,
        gpu_device=gpu_device,
    )

    if options.default_backend is None:
        options.default_backend = client

    with cf.config_prefix('sql'):
        k = 'default_limit'
        cf.set_option(k, None)

    return client
コード例 #2
0
ファイル: api.py プロジェクト: samagra14/ibis
def connect(
    uri=None,
    user=None,
    password=None,
    host=None,
    port=6274,
    database=None,
    protocol='binary',
    session_id=None,
    execution_type=EXECUTION_TYPE_CURSOR,
):
    """Create a MapDClient for use with Ibis

    Parameters could be

    :param uri: str
    :param user: str
    :param password: str
    :param host: str
    :param port: int
    :param database: str
    :param protocol: str
    :param session_id: str
    :param execution_type: int
    Returns
    -------
    MapDClient

    """
    client = MapDClient(
        uri=uri,
        user=user,
        password=password,
        host=host,
        port=port,
        database=database,
        protocol=protocol,
        session_id=session_id,
        execution_type=execution_type,
    )

    if options.default_backend is None:
        options.default_backend = client

    with cf.config_prefix('sql'):
        k = 'default_limit'
        cf.set_option(k, None)

    return client
コード例 #3
0
ファイル: api.py プロジェクト: scottcode/ibis
def connect(
    uri=None,
    user=None,
    password=None,
    host=None,
    port=6274,
    database=None,
    protocol='binary',
    session_id=None,
    execution_type=EXECUTION_TYPE_CURSOR,
):
    """Create a client for OmniSciDB backend.

    Parameters
    ----------
    uri : str
    user : str
    password : str
    host : str
    port : int
    database : str
    protocol : str
    session_id : str
    execution_type : int

    Returns
    -------
    OmniSciDBClient
    """
    client = OmniSciDBClient(
        uri=uri,
        user=user,
        password=password,
        host=host,
        port=port,
        database=database,
        protocol=protocol,
        session_id=session_id,
        execution_type=execution_type,
    )

    if options.default_backend is None:
        options.default_backend = client

    with cf.config_prefix('sql'):
        k = 'default_limit'
        cf.set_option(k, None)

    return client
コード例 #4
0
ファイル: trace.py プロジェクト: zhuohuwu0603/ibis
def enable():
    """Enable tracing."""
    set_option(_TRACE_CONFIG, True)
    logging.getLogger('ibis.pandas.trace').setLevel(logging.DEBUG)
コード例 #5
0
from typing import Dict, List, Callable

from sqlalchemy import create_engine
from django.core.cache import cache
import pandas as pd
import numpy as np
import ibis
from ibis import config as cf
from ibis.sql.postgres import existing_udf

# local
from dados.episem import episem, episem2date
from ad_main import settings

with cf.config_prefix('sql'):
    cf.set_option('default_limit', None)

# rio de janeiro city geocode
MRJ_GEOCODE = 3304557

CID10 = {'dengue': 'A90', 'chikungunya': 'A920', 'zika': 'A928'}
DISEASES_SHORT = ['dengue', 'chik', 'zika']

STATE_NAME = {
    'CE': 'Ceará',
    'ES': 'Espírito Santo',
    'MG': 'Minas Gerais',
    'PR': 'Paraná',
    'RJ': 'Rio de Janeiro',
    'SP': 'São Paulo',
    'RS': 'Rio Grande do Sul',
コード例 #6
0
ファイル: api.py プロジェクト: safrazRampersaud/ibis-mssql
def connect(
    host='localhost',
    user=None,
    password=None,
    port=1433,
    database='master',
    driver='pyodbc',
    odbc_driver='ODBC Driver 17 for SQL Server',
    url=None,
):
    """Create an Ibis client connected to a MSSQL database.

    Parameters
    ----------
    host : string, default 'localhost'
    user : string, optional
    password : string, optional
    port : string or integer, default 1433
    database : string, default 'master'
    url : string, optional
        Complete SQLAlchemy connection string. If passed, the other connection
        arguments are ignored.
    driver : string, default 'pyodbc'
    odbc_driver : string, default 'ODBC Driver 17 for SQL Server'

    Returns
    -------
    MSSQLClient

    Examples
    --------
    >>> import os
    >>> import getpass
    >>> host = os.environ.get('IBIS_TEST_MSSQL_HOST', 'localhost')
    >>> user = os.environ.get('IBIS_TEST_MSSQL_USER', getpass.getuser())
    >>> password = os.environ.get('IBIS_TEST_MSSQL_PASSWORD')
    >>> database = os.environ.get('IBIS_TEST_MSSQL_DATABASE', 'master')
    >>> con = connect(
    ...     database=database,
    ...     host=host,
    ...     user=user,
    ...     password=password
    ... )
    >>> con.list_tables()  # doctest: +ELLIPSIS
    [...]
    >>> t = con.table('functional_alltypes')
    >>> t
    MSSQLTable[table]
      name: functional_alltypes
      schema:
        index : int64
        Unnamed: 0 : int64
        id : int32
        bool_col : boolean
        tinyint_col : int16
        smallint_col : int16
        int_col : int32
        bigint_col : int64
        float_col : float32
        double_col : float32
        date_string_col : string
        string_col : string
        timestamp_col : timestamp
        year : int32
        month : int32
    """
    client = MSSQLClient(
        host=host,
        user=user,
        password=password,
        port=port,
        database=database,
        url=url,
        driver=driver,
        odbc_driver=odbc_driver,
    )

    if options.default_backend is None:
        options.default_backend = client

    with cf.config_prefix('sql'):
        k = 'default_limit'
        cf.set_option(k, None)

    return client