Get connected databases info

Hi

Whether there is a way to get all available databases (datasources) for current project and get some meta-information about them like displayed in database plugin (table names, column names, etc.) ?

Thanks.

1 comment
Comment actions Permalink

The entry point is a project component

com.intellij.database.psi.DbPsiFacade

 

The database model API (tables, columns, etc.) is in the package

com.intellij.database.model

 

 So you do something like this:

// iterate through all data sources (project and global)
for (DbDataSource dataSource : DbPsiFacade.getInstance(project).getDataSources()) {

// dataSource.getModel().traverser() will list all the objects

// com.intellij.database.util.DasUtil is a convenience class for the same task:
// e.g. iterate through all tables
for (DasTable table : DasUtil.getTables(datasource)) {

}
}
1

Please sign in to leave a comment.