# SQLDatabase

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/utilities/sql_database/SQLDatabase)

SQLAlchemy wrapper around a database.

## Signature

```python
SQLDatabase(
    self,
    engine: Engine,
    schema: Optional[str] = None,
    metadata: Optional[MetaData] = None,
    ignore_tables: Optional[List[str]] = None,
    include_tables: Optional[List[str]] = None,
    sample_rows_in_table_info: int = 3,
    indexes_in_table_info: bool = False,
    custom_table_info: Optional[dict] = None,
    view_support: bool = False,
    max_string_length: int = 300,
    lazy_table_reflection: bool = False,
)
```

## Constructors

```python
__init__(
    self,
    engine: Engine,
    schema: Optional[str] = None,
    metadata: Optional[MetaData] = None,
    ignore_tables: Optional[List[str]] = None,
    include_tables: Optional[List[str]] = None,
    sample_rows_in_table_info: int = 3,
    indexes_in_table_info: bool = False,
    custom_table_info: Optional[dict] = None,
    view_support: bool = False,
    max_string_length: int = 300,
    lazy_table_reflection: bool = False,
)
```

| Name | Type |
|------|------|
| `engine` | `Engine` |
| `schema` | `Optional[str]` |
| `metadata` | `Optional[MetaData]` |
| `ignore_tables` | `Optional[List[str]]` |
| `include_tables` | `Optional[List[str]]` |
| `sample_rows_in_table_info` | `int` |
| `indexes_in_table_info` | `bool` |
| `custom_table_info` | `Optional[dict]` |
| `view_support` | `bool` |
| `max_string_length` | `int` |
| `lazy_table_reflection` | `bool` |


## Properties

- `dialect`
- `table_info`

## Methods

- [`from_uri()`](https://reference.langchain.com/python/langchain-community/utilities/sql_database/SQLDatabase/from_uri)
- [`from_databricks()`](https://reference.langchain.com/python/langchain-community/utilities/sql_database/SQLDatabase/from_databricks)
- [`from_cnosdb()`](https://reference.langchain.com/python/langchain-community/utilities/sql_database/SQLDatabase/from_cnosdb)
- [`get_usable_table_names()`](https://reference.langchain.com/python/langchain-community/utilities/sql_database/SQLDatabase/get_usable_table_names)
- [`get_table_names()`](https://reference.langchain.com/python/langchain-community/utilities/sql_database/SQLDatabase/get_table_names)
- [`get_table_info()`](https://reference.langchain.com/python/langchain-community/utilities/sql_database/SQLDatabase/get_table_info)
- [`run()`](https://reference.langchain.com/python/langchain-community/utilities/sql_database/SQLDatabase/run)
- [`get_table_info_no_throw()`](https://reference.langchain.com/python/langchain-community/utilities/sql_database/SQLDatabase/get_table_info_no_throw)
- [`run_no_throw()`](https://reference.langchain.com/python/langchain-community/utilities/sql_database/SQLDatabase/run_no_throw)
- [`get_context()`](https://reference.langchain.com/python/langchain-community/utilities/sql_database/SQLDatabase/get_context)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/a6a6079511ac8a5c1293337f88096b8641562e77/libs/community/langchain_community/utilities/sql_database.py#L83)