sybase Adapter¶
from sqlspec.adapters.sybase import (
SybaseConfig,
SybaseConnectionParams,
SybaseConnectionPool,
SybaseDriver,
SybaseDriverFeatures,
SybaseExceptionHandler,
SybasePoolParams,
SybaseSyncDataDictionary,
SybaseSyncMigrationTracker,
)
Synchronous SAP Adaptive Server Enterprise (Sybase ASE) 16.0+ adapter built on pymssql over FreeTDS TDS 5.0 wire protocol. Inherited execution methods are documented on SyncDriverAdapterBase. See the Sybase ASE Setup Guide for TDS 5.0 protocol negotiation and connection pooling, and the Sybase Data Dictionary & SQL Catalog for system catalog introspection queries.
Configuration & Parameters¶
SybaseConfig
¶
SybaseConfig(
*,
connection_config: SybasePoolParams | dict[str, Any] | None = None,
connection_instance: SybaseConnectionPool | None = None,
migration_config: dict[str, Any] | None = None,
statement_config: StatementConfig | None = None,
driver_features: SybaseDriverFeatures | dict[str, Any] | None = None,
bind_key: str | None = None,
extension_config: ExtensionConfigs | None = None,
observability_config: ObservabilityConfig | None = None,
**kwargs: Any,
)
Bases: SyncDatabaseConfig[SybaseConnection, SybaseConnectionPool, SybaseDriver]
Configuration for Sybase ASE synchronous connections over pymssql (FreeTDS TDS 5.0).
Methods:
| Name | Description |
|---|---|
create_connection |
Open a standalone Sybase ASE connection owned by the caller. |
get_signature_namespace |
|
get_event_runtime_hints |
Return runtime hints for Sybase ASE event channels. |
Attributes:
| Name | Type | Description |
|---|---|---|
driver_type |
type[SybaseDriver]
|
|
connection_type |
type[SybaseConnection]
|
|
migration_tracker_type |
type[SybaseSyncMigrationTracker]
|
|
supports_transactional_ddl |
bool
|
|
supports_migration_schemas |
bool
|
|
supports_native_arrow_export |
bool
|
|
supports_native_arrow_import |
bool
|
|
supports_native_parquet_export |
bool
|
|
supports_native_parquet_import |
bool
|
|
supports_native_row_streaming |
bool
|
|
type_coercion_capabilities |
TypeCoercionCapabilities
|
|
create_connection
¶
Open a standalone Sybase ASE connection owned by the caller.
get_event_runtime_hints
¶
get_event_runtime_hints() -> EventRuntimeHints
Return runtime hints for Sybase ASE event channels.
SybaseConnectionParams
¶
Bases: TypedDict
Sybase ASE connection parameters.
Attributes:
| Name | Type | Description |
|---|---|---|
server |
NotRequired[str]
|
Database server host, IP, or FreeTDS server definition name. |
host |
NotRequired[str]
|
Alias for |
freetds_server |
NotRequired[str]
|
FreeTDS server configuration section name. |
server_alias |
NotRequired[str]
|
Alias for |
user |
NotRequired[str]
|
Login user name. |
username |
NotRequired[str]
|
Alias for |
password |
NotRequired[str]
|
Authentication password. |
database |
NotRequired[str]
|
Initial database name to connect to. |
db |
NotRequired[str]
|
Alias for |
port |
NotRequired[int | str]
|
TCP port number of the Sybase ASE server. |
timeout |
NotRequired[SybaseTimeout]
|
Query execution timeout in seconds. |
login_timeout |
NotRequired[SybaseTimeout]
|
Login and connection timeout in seconds. |
charset |
NotRequired[str]
|
Client character set encoding. |
as_dict |
NotRequired[bool]
|
Return query result rows as dictionaries. |
appname |
NotRequired[str]
|
Application name sent to the server for connection identification. |
conn_properties |
NotRequired[str]
|
Additional connection properties string. |
autocommit |
NotRequired[bool]
|
Enable autocommit mode for transactions. |
tds_version |
NotRequired[str]
|
TDS protocol version (such as |
encryption |
NotRequired[Literal['off', 'request', 'require']]
|
TDS connection encryption level. |
arraysize |
NotRequired[int]
|
Default cursor fetch array size. |
conv |
NotRequired[Mapping[int | type[Any], Callable[..., Any]]]
|
Custom datatype conversion dictionary mapping TDS types to python types. |
read_only |
NotRequired[bool]
|
Enforce read-only transactions on connections. |
pool_recycle_seconds |
NotRequired[int]
|
Maximum age in seconds before a pooled connection is recycled. |
health_check_interval |
NotRequired[float]
|
Interval in seconds between background health checks. |
extra |
NotRequired[dict[str, Any]]
|
Additional driver connection arguments. |
SybasePoolParams
¶
SybaseDriverFeatures
¶
Bases: TypedDict
Sybase ASE driver feature flags.
Attributes:
| Name | Type | Description |
|---|---|---|
json_serializer |
NotRequired[Callable[[Any], str]]
|
Custom callable for serializing objects to JSON strings. |
json_deserializer |
NotRequired[Callable[[str], Any]]
|
Custom callable for deserializing JSON strings. |
on_connection_create |
NotRequired[Callable[[SybaseConnection], None]]
|
Callback invoked immediately when a new connection is established. |
enable_events |
NotRequired[bool]
|
Enable database event listening. |
events_backend |
NotRequired[Literal['poll_queue']]
|
Backend mechanism used for dispatching events. |
Driver, Pool & Data Dictionary¶
SybaseDriver
¶
SybaseDriver(
connection: SybaseConnection,
statement_config: StatementConfig | None = None,
driver_features: dict[str, Any] | None = None,
)
Bases: SyncDriverAdapterBase
Sybase Adaptive Server Enterprise database driver using pymssql over FreeTDS TDS 5.0.
Attributes:
| Name | Type | Description |
|---|---|---|
dialect |
|
|
data_dictionary |
SybaseSyncDataDictionary
|
|
SybaseExceptionHandler
¶
SybaseConnectionPool
¶
SybaseConnectionPool(
connection_parameters: dict[str, Any],
recycle_seconds: int = 86400,
health_check_interval: float = 30.0,
on_connection_create: Callable[[SybaseConnection], None] | None = None,
)
Thread-local connection manager for Sybase ASE over pymssql (FreeTDS TDS 5.0).
Initialize the thread-local Sybase ASE connection manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection_parameters
|
dict[str, Any]
|
Normalized Sybase connection parameters. |
required |
recycle_seconds
|
int
|
Connection recycle time in seconds (default 24h). |
86400
|
health_check_interval
|
float
|
Seconds of idle time before running health check. |
30.0
|
on_connection_create
|
Callable[[SybaseConnection], None] | None
|
Callback executed when a connection is created. |
None
|
Methods:
| Name | Description |
|---|---|
new_connection |
Open a standalone Sybase ASE connection using FreeTDS TDS 5.0 negotiation. |
get_connection |
Get a thread-local connection. |
close |
Close every connection this pool opened, on any thread. |
acquire |
|
release |
|
size |
|
checked_out |
|
new_connection
¶
Open a standalone Sybase ASE connection using FreeTDS TDS 5.0 negotiation.
Returns:
| Name | Type | Description |
|---|---|---|
SybaseConnection |
SybaseConnection
|
A newly opened, fully configured connection. |
get_connection
¶
Get a thread-local connection.
Yields:
| Type | Description |
|---|---|
SybaseConnection
|
A thread-local database connection. |
SybaseSyncDataDictionary
¶
Bases: SyncDataDictionaryBase
Sybase ASE sync data dictionary for metadata reflection.
Initialize Sybase ASE sync data dictionary.
Attributes:
| Name | Type | Description |
|---|---|---|
dialect |
str
|
|
SybaseSyncMigrationTracker
¶
Extension Stores & Configs¶
SybaseStore
¶
SybaseStore(config: SybaseConfig)
Bases: BaseSQLSpecStore['SybaseConfig']
Sybase ASE-backed session store using pymssql sync sessions.
Methods:
| Name | Description |
|---|---|
create_table |
Create the session table if it doesn't exist. |
get |
Get a session value by key. |
set |
Store a session value. |
delete |
Delete a session by key. |
delete_all |
Delete all sessions from the store. |
exists |
Check if a session key exists and is not expired. |
expires_in |
Get the time in seconds until the session expires. |
delete_expired |
Delete all expired sessions. |
SybaseADKStore
¶
SybaseADKStore(config: SybaseConfig)
Bases: BaseSyncADKStore['SybaseConfig']
Synchronous Sybase ASE ADK session/event store.
Methods:
| Name | Description |
|---|---|
create_tables |
Create ADK tables (idempotent Sybase ASE DDL) and DD-gated indexes. |
create_session |
Create a new ADK session. |
get_session |
Return a scoped session or |
update_session_state |
Replace a session's durable state. |
list_sessions |
List ADK sessions for an application, optionally scoped to a user. |
delete_session |
Delete a session and its associated events. |
append_event |
Append an event to a session. |
append_event_and_update_state |
Atomically append an event and update durable session/scoped state. |
get_events |
Return events for a scoped session ordered by event timestamp. |
delete_expired_events |
Delete events older than |
delete_idle_sessions |
Delete sessions whose update_time is older than |
delete_idle_user_states |
Delete user state rows whose update_time is older than |
get_app_state |
Return app-scoped state. |
get_user_state |
Return user-scoped state. |
upsert_app_state |
Insert or replace app-scoped state. |
upsert_user_state |
Insert or replace user-scoped state. |
get_metadata |
Return an ADK metadata value. |
set_metadata |
Set an ADK metadata value. |
Attributes:
| Name | Type | Description |
|---|---|---|
connector_name |
str
|
|
create_tables
¶
Create ADK tables (idempotent Sybase ASE DDL) and DD-gated indexes.
create_session
¶
create_session(
session_id: str,
app_name: str,
user_id: str,
state: dict[str, Any],
owner_id: Any | None = None,
) -> StoredSession
Create a new ADK session.
get_session
¶
get_session(
app_name: str,
user_id: str,
session_id: str,
*,
renew_for: int | timedelta | None = None,
) -> StoredSession | None
Return a scoped session or None if absent.
update_session_state
¶
Replace a session's durable state.
list_sessions
¶
list_sessions(
app_name: str,
user_id: str | None = None,
*,
order_by: SessionOrderBy = "update_time",
descending: bool = True,
limit: int | None = None,
offset: int | None = None,
) -> list[StoredSession]
List ADK sessions for an application, optionally scoped to a user.
delete_session
¶
Delete a session and its associated events.
append_event_and_update_state
¶
append_event_and_update_state(
event_record: StoredEvent,
app_name: str,
user_id: str,
session_id: str,
state: dict[str, Any],
*,
app_state: dict[str, Any] | None = None,
user_state: dict[str, Any] | None = None,
) -> StoredSession
Atomically append an event and update durable session/scoped state.
get_events
¶
get_events(
app_name: str,
user_id: str,
session_id: str,
after_timestamp: datetime | None = None,
limit: int | None = None,
) -> list[StoredEvent]
Return events for a scoped session ordered by event timestamp.
delete_expired_events
¶
Delete events older than before.
delete_idle_sessions
¶
Delete sessions whose update_time is older than updated_before.
delete_idle_user_states
¶
Delete user state rows whose update_time is older than updated_before.
get_user_state
¶
Return user-scoped state.
upsert_app_state
¶
Insert or replace app-scoped state.
upsert_user_state
¶
Insert or replace user-scoped state.
SybaseADKMemoryStore
¶
SybaseADKMemoryStore(config: SybaseConfig)
Bases: BaseSyncADKMemoryStore['SybaseConfig']
Sybase ASE ADK memory store using pymssql.
Methods:
| Name | Description |
|---|---|
create_tables |
Create the memory table (idempotent Sybase ASE DDL) and DD-gated indexes. |
insert_memory_entries |
Bulk insert memory entries with event-id deduplication. |
search_entries |
Search memory entries by text query. |
delete_entries_by_session |
Delete all memory entries for a specific session. |
delete_entries_older_than |
Delete memory entries older than the retention window. |
create_tables
¶
Create the memory table (idempotent Sybase ASE DDL) and DD-gated indexes.
insert_memory_entries
¶
insert_memory_entries(
entries: list[StoredMemory], owner_id: object | None = None
) -> int
Bulk insert memory entries with event-id deduplication.
search_entries
¶
search_entries(
query: str,
app_name: str,
user_id: str,
limit: int | None = None,
scope_filter: Literal["all", "user", "app"] = "all",
embedding: Sequence[float] | None = None,
) -> list[StoredMemory]
Search memory entries by text query.
delete_entries_by_session
¶
Delete all memory entries for a specific session.
delete_entries_older_than
¶
delete_entries_older_than(
days: int, app_name: str | None = None, scope: str | None = None
) -> int
Delete memory entries older than the retention window.