1 # Low-level connections
 
   3 The `NominatimAPIAsync` class allows to directly access the underlying
 
   4 database connection to explore the raw data. Nominatim uses
 
   5 [SQLAlchemy](https://docs.sqlalchemy.org/) for building queries. Please
 
   6 refer to the documentation of the library to understand how to write SQL.
 
   8 To get access to a search connection, use the `begin()` function of your
 
   9 API object. This returns a `SearchConnection` object described below
 
  10 wrapped in a context manager. Its
 
  11 `t` property has definitions for all Nominatim search tables. For an
 
  12 overview of available tables, refer to the
 
  13 [Development Layout](../develop/Database-Layout.md) in in the development
 
  14 chapter. Note that only tables that are needed for search are accessible
 
  18     The database layout is not part of the API definition and may change
 
  19     without notice. If you play with the low-level access functions, you
 
  20     need to be prepared for such changes.
 
  22 Here is a simple example, which prints how many places are available in
 
  27 from pathlib import Path
 
  28 import sqlalchemy as sa
 
  29 from nominatim.api import NominatimAPIAsync
 
  31 async def print_table_size():
 
  32     api = NominatimAPIAsync(Path('.'))
 
  34     async with api.begin() as conn:
 
  35         cnt = await conn.scalar(sa.select(sa.func.count()).select_from(conn.t.placex))
 
  36         print(f'placex table has {cnt} rows.')
 
  38 asyncio.run(print_table_size())
 
  42     Low-level connections may only be used to read data from the database.
 
  43     Do not use it to add or modify data or you might break Nominatim's
 
  46 ## SearchConnection class
 
  48 ::: nominatim.api.SearchConnection