Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
singlestore-labs
GitHub Repository: singlestore-labs/singlestoredb-python
Path: blob/main/singlestoredb/__init__.py
469 views
1
#!/usr/bin/env python
2
"""
3
SingleStoreDB module.
4
5
Examples
6
--------
7
>>> import singlestoredb as s2
8
>>> conn = s2.connect('user:password@host/dbname')
9
>>> cur = conn.cursor()
10
>>> cur.execute('select * from customers')
11
>>> for row in cur:
12
... print(row)
13
14
"""
15
16
__version__ = '1.15.4'
17
18
from typing import Any
19
20
from .config import options, get_option, set_option, describe_option
21
from .connection import connect, apilevel, threadsafety, paramstyle
22
from .exceptions import (
23
Warning, Error, InterfaceError, DatabaseError, OperationalError,
24
IntegrityError, InternalError, ProgrammingError, NotSupportedError,
25
DataError, ManagementError,
26
)
27
from .management import (
28
manage_cluster, manage_workspaces, manage_files, manage_regions,
29
)
30
from .types import (
31
Date, Time, Timestamp, DateFromTicks, TimeFromTicks, TimestampFromTicks,
32
Binary, STRING, BINARY, NUMBER, DATETIME, ROWID,
33
)
34
# These are only loaded if the singlestore-vectorstore package is available
35
try:
36
from .vectorstore import (
37
vector_db, IndexInterface, IndexList, IndexModel, MatchTypedDict,
38
Metric, IndexStatsTypedDict, NamespaceStatsTypedDict, Vector,
39
VectorDictMetadataValue, VectorMetadataTypedDict, VectorTuple,
40
VectorTupleWithMetadata, DeletionProtection, AndFilter, EqFilter,
41
ExactMatchFilter, FilterTypedDict, GteFilter, GtFilter, InFilter,
42
LteFilter, LtFilter, NeFilter, NinFilter, OrFilter, SimpleFilter,
43
)
44
except (ImportError, ModuleNotFoundError):
45
pass
46
47
48
#
49
# This function is defined here to prevent the side-effect of
50
# attempting to load the SQLAlchemy dialect in the core SDK.
51
#
52
def create_engine(*args: Any, **kwargs: Any) -> Any:
53
"""
54
Create an SQLAlchemy engine for SingleStoreDB.
55
56
Parameters
57
----------
58
**kwargs : Any
59
The parameters taken here are the same as for
60
`sqlalchemy.create_engine`. However, this function can be
61
called without any parameters in order to inherit parameters
62
set by environment variables or parameters set in by
63
options in Python code.
64
65
See Also
66
--------
67
`sqlalchemy.create_engine`
68
69
Returns
70
-------
71
SQLAlchemy engine
72
73
"""
74
from .alchemy import create_engine
75
return create_engine(*args, **kwargs)
76
77