Path: blob/main/singlestoredb/vectorstore.py
469 views
from typing import Any1from typing import Callable2from typing import Dict3from typing import Optional45from vectorstore import AndFilter # noqa: F4016from vectorstore import DeletionProtection # noqa: F4017from vectorstore import EqFilter # noqa: F4018from vectorstore import ExactMatchFilter # noqa: F4019from vectorstore import FilterTypedDict # noqa: F40110from vectorstore import GteFilter # noqa: F40111from vectorstore import GtFilter # noqa: F40112from vectorstore import IndexInterface # noqa: F40113from vectorstore import IndexList # noqa: F40114from vectorstore import IndexModel # noqa: F40115from vectorstore import IndexStatsTypedDict # noqa: F40116from vectorstore import InFilter # noqa: F40117from vectorstore import LteFilter # noqa: F40118from vectorstore import LtFilter # noqa: F40119from vectorstore import MatchTypedDict # noqa: F40120from vectorstore import Metric # noqa: F40121from vectorstore import NamespaceStatsTypedDict # noqa: F40122from vectorstore import NeFilter # noqa: F40123from vectorstore import NinFilter # noqa: F40124from vectorstore import OrFilter # noqa: F40125from vectorstore import SimpleFilter # noqa: F40126from vectorstore import Vector # noqa: F40127from vectorstore import VectorDictMetadataValue # noqa: F40128from vectorstore import VectorMetadataTypedDict # noqa: F40129from vectorstore import VectorTuple # noqa: F40130from vectorstore import VectorTupleWithMetadata # noqa: F401313233def vector_db(34host: Optional[str] = None, user: Optional[str] = None,35password: Optional[str] = None, port: Optional[int] = None,36database: Optional[str] = None, driver: Optional[str] = None,37pure_python: Optional[bool] = None, local_infile: Optional[bool] = None,38charset: Optional[str] = None,39ssl_key: Optional[str] = None, ssl_cert: Optional[str] = None,40ssl_ca: Optional[str] = None, ssl_disabled: Optional[bool] = None,41ssl_cipher: Optional[str] = None, ssl_verify_cert: Optional[bool] = None,42tls_sni_servername: Optional[str] = None,43ssl_verify_identity: Optional[bool] = None,44conv: Optional[Dict[int, Callable[..., Any]]] = None,45credential_type: Optional[str] = None,46autocommit: Optional[bool] = None,47results_type: Optional[str] = None,48buffered: Optional[bool] = None,49results_format: Optional[str] = None,50program_name: Optional[str] = None,51conn_attrs: Optional[Dict[str, str]] = {},52multi_statements: Optional[bool] = None,53client_found_rows: Optional[bool] = None,54connect_timeout: Optional[int] = None,55nan_as_null: Optional[bool] = None,56inf_as_null: Optional[bool] = None,57encoding_errors: Optional[str] = None,58track_env: Optional[bool] = None,59enable_extended_data_types: Optional[bool] = None,60vector_data_format: Optional[str] = None,61parse_json: Optional[bool] = None,62pool_size: Optional[int] = 5,63max_overflow: Optional[int] = 10,64timeout: Optional[float] = 30,65) -> Any:66"""67Return a vectorstore API connection.68Database should be specified in the URL or as a keyword.6970Parameters71----------72host : str, optional73Hostname, IP address, or URL that describes the connection.74The scheme or protocol defines which database connector to use.75By default, the ``mysql`` scheme is used. To connect to the76HTTP API, the scheme can be set to ``http`` or ``https``. The username,77password, host, and port are specified as in a standard URL. The path78indicates the database name. The overall form of the URL is:79``scheme://user:password@host:port/db_name``. The scheme can80typically be left off (unless you are using the HTTP API):81``user:password@host:port/db_name``.82user : str, optional83Database user name84password : str, optional85Database user password86port : int, optional87Database port. This defaults to 3306 for non-HTTP connections, 8088for HTTP connections, and 443 for HTTPS connections.89database : str, optional90Database name.91pure_python : bool, optional92Use the connector in pure Python mode93local_infile : bool, optional94Allow local file uploads95charset : str, optional96Character set for string values97ssl_key : str, optional98File containing SSL key99ssl_cert : str, optional100File containing SSL certificate101ssl_ca : str, optional102File containing SSL certificate authority103ssl_cipher : str, optional104Sets the SSL cipher list105ssl_disabled : bool, optional106Disable SSL usage107ssl_verify_cert : bool, optional108Verify the server's certificate. This is automatically enabled if109``ssl_ca`` is also specified.110ssl_verify_identity : bool, optional111Verify the server's identity112conv : dict[int, Callable], optional113Dictionary of data conversion functions114credential_type : str, optional115Type of authentication to use: auth.PASSWORD, auth.JWT, or auth.BROWSER_SSO116autocommit : bool, optional117Enable autocommits118results_type : str, optional119The form of the query results: tuples, namedtuples, dicts,120numpy, polars, pandas, arrow121buffered : bool, optional122Should the entire query result be buffered in memory? This is the default123behavior which allows full cursor control of the result, but does consume124more memory.125results_format : str, optional126Deprecated. This option has been renamed to results_type.127program_name : str, optional128Name of the program129conn_attrs : dict, optional130Additional connection attributes for telemetry. Example:131{'program_version': "1.0.2", "_connector_name": "dbt connector"}132multi_statements: bool, optional133Should multiple statements be allowed within a single query?134connect_timeout : int, optional135The timeout for connecting to the database in seconds.136(default: 10, min: 1, max: 31536000)137nan_as_null : bool, optional138Should NaN values be treated as NULLs when used in parameter139substitutions including uploaded data?140inf_as_null : bool, optional141Should Inf values be treated as NULLs when used in parameter142substitutions including uploaded data?143encoding_errors : str, optional144The error handler name for value decoding errors145track_env : bool, optional146Should the connection track the SINGLESTOREDB_URL environment variable?147enable_extended_data_types : bool, optional148Should extended data types (BSON, vector) be enabled?149vector_data_format : str, optional150Format for vector types: json or binary151pool_size : int, optional152The number of connections to keep in the connection pool. Default is 5.153max_overflow : int, optional154The maximum number of connections to allow beyond the pool size.155Default is 10.156timeout : float, optional157The timeout for acquiring a connection from the pool in seconds.158Default is 30 seconds.159160See Also161--------162:class:`Connection`163164Returns165-------166:class:`VectorDB`167168"""169from vectorstore import VectorDB170return VectorDB(171host=host, user=user, password=password, port=port,172database=database, driver=driver, pure_python=pure_python,173local_infile=local_infile, charset=charset,174ssl_key=ssl_key, ssl_cert=ssl_cert, ssl_ca=ssl_ca,175ssl_disabled=ssl_disabled, ssl_cipher=ssl_cipher,176ssl_verify_cert=ssl_verify_cert,177tls_sni_servername=tls_sni_servername,178ssl_verify_identity=ssl_verify_identity, conv=conv,179credential_type=credential_type, autocommit=autocommit,180results_type=results_type, buffered=buffered,181results_format=results_format, program_name=program_name,182conn_attrs=conn_attrs, multi_statements=multi_statements,183client_found_rows=client_found_rows,184connect_timeout=connect_timeout, nan_as_null=nan_as_null,185inf_as_null=inf_as_null, encoding_errors=encoding_errors,186track_env=track_env,187enable_extended_data_types=enable_extended_data_types,188vector_data_format=vector_data_format,189parse_json=parse_json, pool_size=pool_size,190max_overflow=max_overflow, timeout=timeout,191)192193194