├── dotnet-dbinfo
├── Properties
│ └── launchSettings.json
├── SupportedDatabaseType.cs
├── dotnet-dbinfo.csproj
├── InfoCollectors
│ ├── MongoDbInfoCollector.cs
│ ├── CosmosDbInfoCollector.cs
│ ├── DynamoDbInfoCollector.cs
│ └── SqlServerInfoCollector.cs
├── Helpers.cs
└── Program.cs
├── .gitignore
├── LICENSE
├── dotnet-dbinfo.sln
└── README.md
/dotnet-dbinfo/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "dotnet-dbinfo": {
4 | "commandName": "Project"
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/dotnet-dbinfo/SupportedDatabaseType.cs:
--------------------------------------------------------------------------------
1 | namespace dotnet_dbinfo
2 | {
3 | public enum SupportedDatabaseType
4 | {
5 | SQLSERVER,
6 | DYNAMODB,
7 | COSMOSDB,
8 | MONGODB,
9 | SQLAZURE
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3 | ################################################################################
4 |
5 | /.vs
6 | /.vscode
7 | /*/obj
8 | /*/bin
9 | /*/.vscode
10 | *.dbmdl
11 | *.jfm
12 | /packages
13 | *.user
14 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/dotnet-dbinfo.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27703.2018
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-dbinfo", "dotnet-dbinfo\dotnet-dbinfo.csproj", "{772F133A-EF5E-48BD-AAAF-3F7B1E4B5D0A}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {772F133A-EF5E-48BD-AAAF-3F7B1E4B5D0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {772F133A-EF5E-48BD-AAAF-3F7B1E4B5D0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {772F133A-EF5E-48BD-AAAF-3F7B1E4B5D0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {772F133A-EF5E-48BD-AAAF-3F7B1E4B5D0A}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {56F67413-77E7-42FC-AEDE-C271BA633A4E}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/dotnet-dbinfo/dotnet-dbinfo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 | dotnet_dbinfo
7 | true
8 | berkid89
9 |
10 |
11 | 1.4.0
12 | A simple command-line tool for get useful database information (in json format). Supported ones: Microsoft SQL Server, AWS DynamoDb, Azure CosmosDb, MongoDb
13 | https://github.com/berkid89/dotnet-dbinfo
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/dotnet-dbinfo/InfoCollectors/MongoDbInfoCollector.cs:
--------------------------------------------------------------------------------
1 | using MongoDB.Driver;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using static dotnet_dbinfo.Helpers;
5 |
6 | namespace dotnet_dbinfo.InfoCollectors
7 | {
8 | public static class MongoDbInfoCollector
9 | {
10 | public static object CollectMongoDbInfo(MongoClient conn, string database)
11 | {
12 | var db = conn.GetDatabase(database);
13 |
14 | return new
15 | {
16 | general = GetGeneralInfo(db),
17 | collections = GetCollectionInfo(db),
18 | };
19 | }
20 |
21 | private static object GetGeneralInfo(IMongoDatabase db) =>
22 | new
23 | {
24 | DatabaseId = db.DatabaseNamespace.DatabaseName,
25 | };
26 |
27 | private static IEnumerable