cardinal_pythonlib.sqlalchemy.dialect


Original code copyright (C) 2009-2022 Rudolf Cardinal (rudolf@pobox.com).

This file is part of cardinal_pythonlib.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Helper functions relating to SQLAlchemy SQL dialects.

class cardinal_pythonlib.sqlalchemy.dialect.SqlaDialectName

Dialect names used by SQLAlchemy.

cardinal_pythonlib.sqlalchemy.dialect.get_dialect(mixed: SQLCompiler | Engine | Dialect) Dialect

Finds the SQLAlchemy dialect in use.

Parameters:

mixed – an SQLAlchemy SQLCompiler, Engine, or Dialect object

Returns: the SQLAlchemy Dialect being used

cardinal_pythonlib.sqlalchemy.dialect.get_dialect_from_name(dialect_name: str) Dialect

Creates a Dialect. Not very elegant.

cardinal_pythonlib.sqlalchemy.dialect.get_dialect_name(mixed: SQLCompiler | Engine | Dialect) str

Finds the name of the SQLAlchemy dialect in use.

Parameters:

mixed – an SQLAlchemy SQLCompiler, Engine, or Dialect object

Returns: the SQLAlchemy dialect name being used

cardinal_pythonlib.sqlalchemy.dialect.get_preparer(mixed: SQLCompiler | Engine | Dialect) IdentifierPreparer

Returns the SQLAlchemy IdentifierPreparer in use for the dialect being used.

Parameters:

mixed – an SQLAlchemy SQLCompiler, Engine, or Dialect object

Returns: an IdentifierPreparer

cardinal_pythonlib.sqlalchemy.dialect.quote_identifier(identifier: str, mixed: SQLCompiler | Engine | Dialect) str

Converts an SQL identifier to a quoted version, via the SQL dialect in use.

Parameters:
  • identifier – the identifier to be quoted

  • mixed – an SQLAlchemy SQLCompiler, Engine, or Dialect object

Returns:

the quoted identifier