dbcrawler轻量级数据库结构爬虫

联合创作 · 2023-10-01 02:46

dbcrawler是一个轻量级数据库结构爬虫。它能够取得数据库的底层结构并返回POJO对象。可以利用其提供的统一API来取得各种不同的数据库系统 的结构,而不用关心这些dbms之间的差异,当底层dbms变化时还是会返回相同的POJO对象。dbcrawler当前只支持MySQL、 PostgreSQL、Apache Derby三种数据库。

示例代码:

DataBase dataBase = DBcrawlerUtility.getDataBase(connection, ConfigEnum.MAXIMUM);
//fetch the DBMS information
RDBMSInfo rdbmsInfo = dataBase.getRDBMSInfo();
System.out.println("rdbmsInfo:" + rdbmsInfo);
//Return Schemas
Set<Schema> schemas = dataBase.getSchemas();
//Iterate to Fetch the schema information and Tables
for(Schema schema : schemas)
{
   
System.out.println("SchemaName :" + schema.getSchamaName());
   
Set<Table> tables = schema.getTables();
   
//Iterate to fetch the tables
   
for(Table table : tables)
   
{
     
System.out.println("tableName :" + table.getTableName());
     
PrimaryKey primaryKey = table.getPrimaryKey();
     
Set<Column> columns = table.getColumns();
   
}
}
浏览 4
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报