diff --git a/docs/by-example/sqlalchemy/inspection-reflection.rst b/docs/by-example/sqlalchemy/inspection-reflection.rst index 92611325d..140813ca5 100644 --- a/docs/by-example/sqlalchemy/inspection-reflection.rst +++ b/docs/by-example/sqlalchemy/inspection-reflection.rst @@ -15,18 +15,21 @@ The `runtime inspection API`_ provides the ``inspect()`` function, which delivers runtime information about a wide variety of SQLAlchemy objects, both within SQLAlchemy Core and the SQLAlchemy ORM. -A low level interface which provides a backend-agnostic system of loading lists -of schema, table, column, and constraint descriptions from a given database is -available. This is known as the `SQLAlchemy inspector`_. +The ``CrateDialect`` instance provides metadata about the CrateDB cluster, +like version and schema information. >>> import sqlalchemy as sa - >>> engine = sa.create_engine(f"crate://{crate_host}") - >>> inspector = sa.inspect(engine) -Inspector usage -=============== +Inspector +========= + +The `SQLAlchemy inspector`_ is a low level interface which provides a backend- +agnostic system of loading lists of schema, table, column, and constraint +descriptions from a given database is available. + + >>> inspector = sa.inspect(engine) List all schemas: @@ -79,6 +82,39 @@ Reflect column data types from the table metadata: PrimaryKeyConstraint(Column('id', String(), table=, primary_key=True... +CrateDialect +============ + +After initializing the dialect instance with a connection instance, + + >>> from crate.client.sqlalchemy.dialect import CrateDialect + >>> dialect = CrateDialect() + + >>> connection = engine.connect() + >>> dialect.initialize(connection) + +the database server version and default schema name can be inquired. + + >>> dialect.server_version_info >= (1, 0, 0) + True + +Check if schema exists: + + >>> dialect.has_schema(connection, 'doc') + True + +Check if table exists: + + >>> dialect.has_table(connection, 'locations') + True + + +.. Hidden: close connection + + >>> connection.close() + >>> engine.dispose() + + .. _reflecting database objects: https://docs.sqlalchemy.org/en/14/core/reflection.html#reflecting-database-objects .. _runtime inspection API: https://docs.sqlalchemy.org/en/14/core/inspection.html .. _SQLAlchemy inspector: https://docs.sqlalchemy.org/en/14/core/reflection.html#fine-grained-reflection-with-inspector diff --git a/docs/by-example/sqlalchemy/internals.rst b/docs/by-example/sqlalchemy/internals.rst deleted file mode 100644 index 9d03f12c6..000000000 --- a/docs/by-example/sqlalchemy/internals.rst +++ /dev/null @@ -1,44 +0,0 @@ -===================== -SQLAlchemy: Internals -===================== - -This section of the documentation, related to CrateDB's SQLAlchemy integration, -focuses on showing specific internals. - - -CrateDialect -============ - -Import the relevant symbols: - - >>> import sqlalchemy as sa - >>> from crate.client.sqlalchemy.dialect import CrateDialect - -Establish a connection to the database: - - >>> engine = sa.create_engine(f"crate://{crate_host}") - >>> connection = engine.connect() - -After initializing the dialect instance with a connection instance, - - >>> dialect = CrateDialect() - >>> dialect.initialize(connection) - -the database server version and default schema name can be inquired. - - >>> dialect.server_version_info >= (1, 0, 0) - True - -Check if schema exists: - - >>> dialect.has_schema(connection, 'doc') - True - -Check if table exists: - - >>> dialect.has_table(connection, 'locations') - True - -.. Hidden: close connection - - >>> connection.close() diff --git a/src/crate/client/tests.py b/src/crate/client/tests.py index 638e54f84..3aa1a13dd 100644 --- a/src/crate/client/tests.py +++ b/src/crate/client/tests.py @@ -337,7 +337,6 @@ def test_suite(): 'docs/by-example/sqlalchemy/getting-started.rst', 'docs/by-example/sqlalchemy/cru.rst', 'docs/by-example/sqlalchemy/inspection-reflection.rst', - 'docs/by-example/sqlalchemy/internals.rst', module_relative=False, setUp=setUpCrateLayerAndSqlAlchemy, tearDown=tearDownWithCrateLayer,