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