# qgis/db_manager_plugin architecture

> Architecture diagram of the GitHub repository qgis/db_manager_plugin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/qgis/db_manager_plugin
- Repository: https://github.com/qgis/db_manager_plugin

## Overview

DB Manager is a QGIS database-browsing and administration plugin. A user opens it from QGIS, browses database connections and objects, then views metadata/data or runs SQL and database operations; vector import/export and PostGIS extensions provide additional capabilities. The graph follows relationships shown in excerpts and the SOURCE INDEX; several driver and extension implementations were not excerpted, so their internal behavior is represented only at subsystem level.

Main entry points: [`db_manager_community/db_manager.py`](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_manager.py) (DB Manager window), [`db_manager_community/db_plugins/connector.py`](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/connector.py) (Connector base), [`db_manager_community/db_plugins/plugin.py`](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/plugin.py) (Driver interface), [`db_manager_community/dlg_sql_window.py`](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/dlg_sql_window.py) (SQL window)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Plugin and browsing"]
  node_plugin_entry["Plugin entry"]
  node_manager["DB Manager window<br/>[db_manager.py]"]
  node_tree["Connection tree<br/>[db_tree.py]"]
end

subgraph group_domain["Database model"]
  node_db_model["Database objects<br/>[db_model.py]"]
  node_plugin_base["Driver interface<br/>[plugin.py]"]
  node_info_model["Metadata models<br/>[info_model.py]"]
  node_data_model["Table data models<br/>[data_model.py]"]
end

subgraph group_drivers["Database drivers"]
  node_connector_base["Connector base<br/>[connector.py]"]
  node_gpkg["GeoPackage driver<br/>[connector.py]"]
  node_postgis["PostGIS driver<br/>[connector.py]"]
  node_spatialite["SpatiaLite driver<br/>[connector.py]"]
  node_oracle["Oracle driver<br/>[connector.py]"]
  node_vlayers["Virtual layers<br/>[connector.py]"]
end

subgraph group_ui["Views and operations"]
  node_info_viewer["Info viewer<br/>[info_viewer.py]"]
  node_table_viewer["Table viewer<br/>[table_viewer.py]"]
  node_preview["Layer preview<br/>[layer_preview.py]"]
  node_sql_window["SQL window<br/>[dlg_sql_window.py]"]
  node_import["Vector import"]
  node_export["Vector export"]
  node_error_dialog["Database errors<br/>[dlg_db_error.py]"]
end

subgraph group_extensions["Driver extensions"]
  node_postgis_plugins["PostGIS extensions"]
end

node_qgis(("QGIS user"))
node_database_services[("Database services")]

node_qgis -->|"opens plugin"| node_plugin_entry
node_plugin_entry -->|"creates window"| node_manager
node_manager -->|"displays connections"| node_tree
node_manager -->|"shows metadata"| node_info_viewer
node_manager -->|"shows table data"| node_table_viewer
node_manager -->|"previews layers"| node_preview
node_manager -->|"opens query"| node_sql_window
node_manager -->|"starts import"| node_import
node_manager -->|"starts export"| node_export
node_tree -->|"presents objects"| node_db_model
node_db_model -->|"uses driver model"| node_plugin_base
node_plugin_base -->|"uses connector API"| node_connector_base
node_plugin_base -->|"provides metadata"| node_info_model
node_plugin_base -->|"provides table models"| node_data_model
node_connector_base -.->|"executes database work"| node_database_services
node_gpkg -->|"extends connector"| node_connector_base
node_postgis -->|"extends connector"| node_connector_base
node_spatialite -->|"extends connector"| node_connector_base
node_oracle -->|"extends connector"| node_connector_base
node_vlayers -->|"extends connector"| node_connector_base
node_info_viewer -->|"requests info"| node_plugin_base
node_sql_window -->|"runs SQL"| node_plugin_base
node_sql_window -->|"reports failures"| node_error_dialog
node_postgis_plugins -.->|"extends PostGIS"| node_postgis

click node_plugin_entry "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_manager_community_plugin.py"
click node_manager "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_manager.py"
click node_tree "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_tree.py"
click node_db_model "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_model.py"
click node_plugin_base "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/plugin.py"
click node_info_model "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/info_model.py"
click node_data_model "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/data_model.py"
click node_connector_base "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/connector.py"
click node_gpkg "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/gpkg/connector.py"
click node_postgis "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/postgis/connector.py"
click node_spatialite "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/spatialite/connector.py"
click node_oracle "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/oracle/connector.py"
click node_vlayers "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/vlayers/connector.py"
click node_info_viewer "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/info_viewer.py"
click node_table_viewer "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/table_viewer.py"
click node_preview "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/layer_preview.py"
click node_sql_window "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/dlg_sql_window.py"
click node_import "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/dlg_import_vector.py"
click node_export "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/dlg_export_vector.py"
click node_postgis_plugins "https://github.com/qgis/db_manager_plugin/tree/main/db_manager_community/db_plugins/postgis/plugins"
click node_error_dialog "https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/dlg_db_error.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_plugin_entry,node_manager,node_tree,node_qgis toneBlue
class node_db_model,node_plugin_base,node_info_model,node_data_model,node_database_services toneAmber
class node_connector_base,node_gpkg,node_postgis,node_spatialite,node_oracle,node_vlayers toneMint
class node_info_viewer,node_table_viewer,node_preview,node_sql_window,node_import,node_export,node_error_dialog toneRose
class node_postgis_plugins toneIndigo
```

## Components

### Plugin and browsing

- [Plugin entry](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_manager_community_plugin.py): `db_manager_community/db_manager_community_plugin.py`
- [DB Manager window](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_manager.py): `db_manager_community/db_manager.py`
- [Connection tree](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_tree.py): `db_manager_community/db_tree.py`

### Database model

- [Database objects](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_model.py): `db_manager_community/db_model.py`
- [Driver interface](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/plugin.py): `db_manager_community/db_plugins/plugin.py`
- [Metadata models](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/info_model.py): `db_manager_community/db_plugins/info_model.py`
- [Table data models](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/data_model.py): `db_manager_community/db_plugins/data_model.py`

### Database drivers

- [Connector base](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/connector.py): `db_manager_community/db_plugins/connector.py`
- [GeoPackage driver](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/gpkg/connector.py): `db_manager_community/db_plugins/gpkg/connector.py`
- [PostGIS driver](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/postgis/connector.py): `db_manager_community/db_plugins/postgis/connector.py`
- [SpatiaLite driver](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/spatialite/connector.py): `db_manager_community/db_plugins/spatialite/connector.py`
- [Oracle driver](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/oracle/connector.py): `db_manager_community/db_plugins/oracle/connector.py`
- [Virtual layers](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/db_plugins/vlayers/connector.py): `db_manager_community/db_plugins/vlayers/connector.py`

### Views and operations

- [Info viewer](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/info_viewer.py): `db_manager_community/info_viewer.py`
- [Table viewer](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/table_viewer.py): `db_manager_community/table_viewer.py`
- [Layer preview](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/layer_preview.py): `db_manager_community/layer_preview.py`
- [SQL window](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/dlg_sql_window.py): `db_manager_community/dlg_sql_window.py`
- [Vector import](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/dlg_import_vector.py): `db_manager_community/dlg_import_vector.py`
- [Vector export](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/dlg_export_vector.py): `db_manager_community/dlg_export_vector.py`
- [Database errors](https://github.com/qgis/db_manager_plugin/blob/main/db_manager_community/dlg_db_error.py): `db_manager_community/dlg_db_error.py`

### Driver extensions

- [PostGIS extensions](https://github.com/qgis/db_manager_plugin/tree/main/db_manager_community/db_plugins/postgis/plugins): `db_manager_community/db_plugins/postgis/plugins`

### Other components

- **QGIS user**
- **Database services**

## Connections

- QGIS user → Plugin entry: opens plugin (evidence: `db_manager_community/db_manager_community_plugin.py`)
- Plugin entry → DB Manager window: creates window (evidence: `db_manager_community/db_manager_community_plugin.py`)
- DB Manager window → Connection tree: displays connections (evidence: `db_manager_community/db_manager.py`)
- DB Manager window → Info viewer: shows metadata (evidence: `db_manager_community/db_manager.py`)
- DB Manager window → Table viewer: shows table data (evidence: `db_manager_community/db_manager.py`)
- DB Manager window → Layer preview: previews layers (evidence: `db_manager_community/db_manager.py`)
- DB Manager window → SQL window: opens query (evidence: `db_manager_community/db_manager.py`)
- DB Manager window → Vector import: starts import (evidence: `db_manager_community/db_manager.py`)
- DB Manager window → Vector export: starts export (evidence: `db_manager_community/db_manager.py`)
- Connection tree → Database objects: presents objects (evidence: `db_manager_community/db_tree.py`)
- Database objects → Driver interface: uses driver model (evidence: `db_manager_community/db_model.py`)
- Driver interface → Connector base: uses connector API (evidence: `db_manager_community/db_plugins/plugin.py`)
- Driver interface → Metadata models: provides metadata (evidence: `db_manager_community/db_plugins/plugin.py`)
- Driver interface → Table data models: provides table models (evidence: `db_manager_community/db_plugins/plugin.py`)
- Connector base → Database services: executes database work
- GeoPackage driver → Connector base: extends connector (evidence: `db_manager_community/db_plugins/gpkg/connector.py`)
- PostGIS driver → Connector base: extends connector (evidence: `db_manager_community/db_plugins/postgis/connector.py`)
- SpatiaLite driver → Connector base: extends connector (evidence: `db_manager_community/db_plugins/spatialite/connector.py`)
- Oracle driver → Connector base: extends connector (evidence: `db_manager_community/db_plugins/oracle/connector.py`)
- Virtual layers → Connector base: extends connector (evidence: `db_manager_community/db_plugins/vlayers/connector.py`)
- Info viewer → Driver interface: requests info (evidence: `db_manager_community/info_viewer.py`)
- SQL window → Driver interface: runs SQL (evidence: `db_manager_community/dlg_sql_window.py`)
- SQL window → Database errors: reports failures (evidence: `db_manager_community/dlg_sql_window.py`)
- PostGIS extensions → PostGIS driver: extends PostGIS
