# -*- coding: utf-8 -*-"""Constant variables used in this project."""importtypingasTimportosfromenum_mate.apiimportBetterStrEnumfrompydanticimportBaseModel,FieldTAB=" "*2
[docs]classLLMColumnConstraintEnum(BetterStrEnum):""" Simplified database column constraints optimized for LLM token efficiency. Used in schema encoding to reduce token usage while preserving essential constraint information. """# relational databasePK="PK"# Primary KeyUQ="UQ"# Unique KeyIDX="IDX"# IndexFK="FK"# Foreign KeyNN="NN"# Not Null# aws redshiftDK="DK"# Distribution KeySK="SK"# Sort Key
[docs]classLLMTypeEnum(BetterStrEnum):""" Simplified database column data types optimized for LLM token efficiency. Used in schema encoding to represent SQL data types with minimal tokens while preserving semantic meaning. """STR="str"# String/text data of any lengthINT="int"# Whole numbers without decimal pointsFLOAT="float"# Approximate decimal numbers (IEEE floating point)DEC="dec"# Exact decimal numbers for currency/financial dataDT="dt"# Date and time combined (local timezone)TS="ts"# Timestamp with timezone information (UTC)DATE="date"# Date only without time componentTIME="time"# Time only without date componentBLOB="blob"# Large binary files (images, documents)BIN="bin"# Small fixed-length binary data (hashes, UUIDs)BOOL="bool"# True/false boolean valuesNULL="null"# Null Type, represents no value
[docs]classObjectTypeEnum(BetterStrEnum):""" Database object types for categorizing different database entities. Used in schema introspection and metadata processing to identify object types. """FOREIGN_KEY="foreign key"COLUMN="column"TABLE="table"VIEW="view"MATERIALIZED_VIEW="materialized view"SCHEMA="schema"DATABASE="database"@propertydeftable_type(self)->"TableTypeEnum":returndb_object_type_to_table_type_mapping[self]
# [startdbtypeenum]
[docs]classDbTypeEnum(BetterStrEnum):""" Supported database system types for connection configuration. Used in configuration validation and connection factory selection. """SQLITE="sqlite"# SQLite local databasesPOSTGRESQL="postgresql"# PostgreSQL databasesMYSQL="mysql"# MySQL/MariaDB databasesMSSQL="mssql"# Microsoft SQL ServerORACLE="oracle"# Oracle databasesAWS_REDSHIFT="aws_redshift"# Amazon Redshift data warehousesSNOWFLAKE="snowflake"# Snowflake cloud databasesMONGODB="mongodb"# MongoDB with SQL interfaceELASTICSEARCH="elasticsearch"# Elasticsearch with SQLOPENSEARCH="opensearch"# OpenSearch with SQL
# [enddbtypeenum]
[docs]classTableTypeEnum(BetterStrEnum):""" Database table types for distinguishing between tables, views, and materialized views. Used in schema introspection and metadata categorization for proper object identification. """TABLE="Table"VIEW="View"MATERIALIZED_VIEW="MaterializedView"
[docs]classConnectionTypeEnum(BetterStrEnum):""" Connection types for database connections. Used in database :class:`~mcp_ohmy_sql.config.conn.BaseConnection` management to differentiate between different connection methods. """SQLALCHEMY="sqlalchemy"# SQLAlchemy connectionsAWS_REDSHIFT="aws_redshift"# AWS Redshift
# [endconnectiontypeenum]
[docs]classEnvVar(BaseModel):""" Environment variable wrapper with default value support. Used for accessing environment variables throughout the application with fallback defaults. """name:str=Field()default:str=Field(default="")@propertydefvalue(self)->str:returnos.environ.get(self.name,self.default)
[docs]classEnvVarEnum:""" Collection of predefined environment variables used throughout the application. Used for centralized environment variable management and configuration loading. """MCP_OHMY_SQL_CONFIG=EnvVar(name="MCP_OHMY_SQL_CONFIG")