-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
58 lines (51 loc) · 1.73 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
using Oracle.ManagedDataAccess.Client;
using DBScanner;
namespace dot101
{
class Program
{
static void Main(string[] args)
{
string dbName = null;
if (args.Length > 0)
{
dbName = args[0];
}
DbConnection conn = new MySqlConnection(@"server=localhost;userid=root;password=root;");
//DbConnection conn = new OracleConnection(@"data source=//localhost:1521;user id=AU_CUSTOMER_PORTAL_MSME;password=Pt#24msmE;");
Scanner scanner = new Scanner(conn);
if (dbName != null)
{
PrintDB(scanner, dbName);
}
else
{
foreach (var db in scanner.GetDatabases())
{
Console.WriteLine("{0}", db);
PrintDB(scanner, db);
}
}
conn.Close();
}
private static void PrintDB(Scanner scanner, string db) {
foreach (var tab in scanner.GetTables(db))
{
Console.WriteLine("\t{0}", tab);
foreach (var col in scanner.GetTableColumns(db, tab))
{
Console.WriteLine("\t\t{0}", col);
}
foreach (var reference in scanner.GetTableReferences(db, tab))
{
Console.WriteLine("\t\t\t{0}", reference);
}
}
}
}
}