1+ from __future__ import annotations
2+ from typing import Optional , Dict , Callable , Any
3+
4+ from vectorstore import (
5+ IndexInterface ,
6+ IndexList ,
7+ IndexModel ,
8+ MatchTypedDict ,
9+ Metric ,
10+ IndexStatsTypedDict ,
11+ NamespaceStatsTypedDict ,
12+ Vector ,
13+ VectorDictMetadataValue ,
14+ VectorMetadataTypedDict ,
15+ VectorTuple ,
16+ VectorTupleWithMetadata ,
17+ DeletionProtection ,
18+ AndFilter ,
19+ EqFilter ,
20+ ExactMatchFilter ,
21+ FilterTypedDict ,
22+ GteFilter ,
23+ GtFilter ,
24+ InFilter ,
25+ LteFilter ,
26+ LtFilter ,
27+ NeFilter ,
28+ NinFilter ,
29+ OrFilter ,
30+ SimpleFilter
31+ )
32+
33+ def vector_db (
34+ host : Optional [str ] = None , user : Optional [str ] = None ,
35+ password : Optional [str ] = None , port : Optional [int ] = None ,
36+ database : Optional [str ] = None , driver : Optional [str ] = None ,
37+ pure_python : Optional [bool ] = None , local_infile : Optional [bool ] = None ,
38+ charset : Optional [str ] = None ,
39+ ssl_key : Optional [str ] = None , ssl_cert : Optional [str ] = None ,
40+ ssl_ca : Optional [str ] = None , ssl_disabled : Optional [bool ] = None ,
41+ ssl_cipher : Optional [str ] = None , ssl_verify_cert : Optional [bool ] = None ,
42+ tls_sni_servername : Optional [str ] = None ,
43+ ssl_verify_identity : Optional [bool ] = None ,
44+ conv : Optional [Dict [int , Callable [..., Any ]]] = None ,
45+ credential_type : Optional [str ] = None ,
46+ autocommit : Optional [bool ] = None ,
47+ results_type : Optional [str ] = None ,
48+ buffered : Optional [bool ] = None ,
49+ results_format : Optional [str ] = None ,
50+ program_name : Optional [str ] = None ,
51+ conn_attrs : Optional [Dict [str , str ]] = {},
52+ multi_statements : Optional [bool ] = None ,
53+ client_found_rows : Optional [bool ] = None ,
54+ connect_timeout : Optional [int ] = None ,
55+ nan_as_null : Optional [bool ] = None ,
56+ inf_as_null : Optional [bool ] = None ,
57+ encoding_errors : Optional [str ] = None ,
58+ track_env : Optional [bool ] = None ,
59+ enable_extended_data_types : Optional [bool ] = None ,
60+ vector_data_format : Optional [str ] = None ,
61+ parse_json : Optional [bool ] = None ,
62+ pool_size : Optional [int ] = 5 ,
63+ max_overflow : Optional [int ] = 10 ,
64+ timeout : Optional [float ] = 30 ,
65+ ) -> "VectorDB" :
66+ """
67+ Return a vectorstore API connection.
68+ Database should be specified in the URL or as a keyword.
69+
70+ Parameters
71+ ----------
72+ host : str, optional
73+ Hostname, IP address, or URL that describes the connection.
74+ The scheme or protocol defines which database connector to use.
75+ By default, the ``mysql`` scheme is used. To connect to the
76+ HTTP API, the scheme can be set to ``http`` or ``https``. The username,
77+ password, host, and port are specified as in a standard URL. The path
78+ indicates the database name. The overall form of the URL is:
79+ ``scheme://user:password@host:port/db_name``. The scheme can
80+ typically be left off (unless you are using the HTTP API):
81+ ``user:password@host:port/db_name``.
82+ user : str, optional
83+ Database user name
84+ password : str, optional
85+ Database user password
86+ port : int, optional
87+ Database port. This defaults to 3306 for non-HTTP connections, 80
88+ for HTTP connections, and 443 for HTTPS connections.
89+ database : str, optional
90+ Database name.
91+ pure_python : bool, optional
92+ Use the connector in pure Python mode
93+ local_infile : bool, optional
94+ Allow local file uploads
95+ charset : str, optional
96+ Character set for string values
97+ ssl_key : str, optional
98+ File containing SSL key
99+ ssl_cert : str, optional
100+ File containing SSL certificate
101+ ssl_ca : str, optional
102+ File containing SSL certificate authority
103+ ssl_cipher : str, optional
104+ Sets the SSL cipher list
105+ ssl_disabled : bool, optional
106+ Disable SSL usage
107+ ssl_verify_cert : bool, optional
108+ Verify the server's certificate. This is automatically enabled if
109+ ``ssl_ca`` is also specified.
110+ ssl_verify_identity : bool, optional
111+ Verify the server's identity
112+ conv : dict[int, Callable], optional
113+ Dictionary of data conversion functions
114+ credential_type : str, optional
115+ Type of authentication to use: auth.PASSWORD, auth.JWT, or auth.BROWSER_SSO
116+ autocommit : bool, optional
117+ Enable autocommits
118+ results_type : str, optional
119+ The form of the query results: tuples, namedtuples, dicts,
120+ numpy, polars, pandas, arrow
121+ buffered : bool, optional
122+ Should the entire query result be buffered in memory? This is the default
123+ behavior which allows full cursor control of the result, but does consume
124+ more memory.
125+ results_format : str, optional
126+ Deprecated. This option has been renamed to results_type.
127+ program_name : str, optional
128+ Name of the program
129+ conn_attrs : dict, optional
130+ Additional connection attributes for telemetry. Example:
131+ {'program_version': "1.0.2", "_connector_name": "dbt connector"}
132+ multi_statements: bool, optional
133+ Should multiple statements be allowed within a single query?
134+ connect_timeout : int, optional
135+ The timeout for connecting to the database in seconds.
136+ (default: 10, min: 1, max: 31536000)
137+ nan_as_null : bool, optional
138+ Should NaN values be treated as NULLs when used in parameter
139+ substitutions including uploaded data?
140+ inf_as_null : bool, optional
141+ Should Inf values be treated as NULLs when used in parameter
142+ substitutions including uploaded data?
143+ encoding_errors : str, optional
144+ The error handler name for value decoding errors
145+ track_env : bool, optional
146+ Should the connection track the SINGLESTOREDB_URL environment variable?
147+ enable_extended_data_types : bool, optional
148+ Should extended data types (BSON, vector) be enabled?
149+ vector_data_format : str, optional
150+ Format for vector types: json or binary
151+ pool_size : int, optional
152+ The number of connections to keep in the connection pool. Default is 5.
153+ max_overflow : int, optional
154+ The maximum number of connections to allow beyond the pool size.
155+ Default is 10.
156+ timeout : float, optional
157+ The timeout for acquiring a connection from the pool in seconds.
158+ Default is 30 seconds.
159+
160+ See Also
161+ --------
162+ :class:`Connection`
163+
164+ Returns
165+ -------
166+ :class:`VectorDB`
167+
168+ """
169+ from vectorstore import VectorDB
170+ return VectorDB (host = host , user = user , password = password , port = port ,
171+ database = database , driver = driver , pure_python = pure_python ,
172+ local_infile = local_infile , charset = charset ,
173+ ssl_key = ssl_key , ssl_cert = ssl_cert , ssl_ca = ssl_ca ,
174+ ssl_disabled = ssl_disabled , ssl_cipher = ssl_cipher ,
175+ ssl_verify_cert = ssl_verify_cert ,
176+ tls_sni_servername = tls_sni_servername ,
177+ ssl_verify_identity = ssl_verify_identity , conv = conv ,
178+ credential_type = credential_type , autocommit = autocommit ,
179+ results_type = results_type , buffered = buffered ,
180+ results_format = results_format , program_name = program_name ,
181+ conn_attrs = conn_attrs , multi_statements = multi_statements ,
182+ client_found_rows = client_found_rows ,
183+ connect_timeout = connect_timeout , nan_as_null = nan_as_null ,
184+ inf_as_null = inf_as_null , encoding_errors = encoding_errors ,
185+ track_env = track_env ,
186+ enable_extended_data_types = enable_extended_data_types ,
187+ vector_data_format = vector_data_format ,
188+ parse_json = parse_json , pool_size = pool_size ,
189+ max_overflow = max_overflow , timeout = timeout )
0 commit comments