Files
zeekay 073c1bf61e rename: zero ClickHouse — datastore_driver speaks X-Datastore-*
The wire protocol was the last holdout and it was not cosmetic: the Hanzo
Datastore server reads X-Datastore-User, and answers a request bearing
X-ClickHouse-User with 401. Verified against the live server, both directions.
So a client still sending the old headers is not merely off-brand, it cannot
authenticate over HTTP.

Everything else follows: types, dialects, error modules, docstrings and doc
links now name Datastore, and doc URLs point at docs.hanzo.ai/datastore rather
than the upstream vendor's site. Zero occurrences of the old name remain.

Still cut from the pinned upstream version, so behaviour is unchanged.
2026-07-26 11:06:05 -07:00

63 lines
1.7 KiB
Python

from .connection import Connection
from .errors import (
Warning, Error, DataError, DatabaseError, ProgrammingError, IntegrityError,
InterfaceError, InternalError, NotSupportedError, OperationalError
)
from .. import defines
apilevel = '2.0'
threadsafety = 2
paramstyle = 'pyformat'
def connect(dsn=None, host=None,
user=defines.DEFAULT_USER, password=defines.DEFAULT_PASSWORD,
port=defines.DEFAULT_PORT, database=defines.DEFAULT_DATABASE,
**kwargs):
"""
Create a new database connection.
The connection can be specified via DSN:
``conn = connect("datastore://localhost/test?param1=value1&...")``
or using database and credentials arguments:
``conn = connect(database="test", user="default", password="default",
host="localhost", **kwargs)``
The basic connection parameters are:
- *host*: host with running Datastore server.
- *port*: port Datastore server is bound to.
- *database*: database connect to.
- *user*: database user.
- *password*: user's password.
See defaults in :data:`~datastore_driver.connection.Connection`
constructor.
DSN or host is required.
Any other keyword parameter will be passed to the underlying Connection
class.
:return: a new connection.
"""
if dsn is None and host is None:
raise ValueError('host or dsn is required')
return Connection(dsn=dsn, user=user, password=password, host=host,
port=port, database=database, **kwargs)
__all__ = [
'connect',
'Warning', 'Error', 'DataError', 'DatabaseError', 'ProgrammingError',
'IntegrityError', 'InterfaceError', 'InternalError', 'NotSupportedError',
'OperationalError'
]