-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get sqlite database filename from user and find tables in that.
- Loading branch information
Showing
2 changed files
with
36 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,50 @@ | ||
using System; | ||
using System.Data; | ||
using Mono.Terminal; | ||
using Mono.Data.SqliteClient; | ||
|
||
namespace Autobahn { | ||
|
||
public class Shell : Container { | ||
|
||
public Shell () : base (0, 0, Application.Cols, Application.Lines) | ||
{ | ||
Add(new Label (0, 0, "Hello World")); | ||
Add (new Label (0, 0, "Hello World")); | ||
} | ||
|
||
static void Main (String [] args) { | ||
|
||
Console.WriteLine ("Hello World"); | ||
|
||
Application.Init (false); | ||
|
||
Shell s = new Shell (); | ||
Application.Run (s); | ||
|
||
if (args.Length != 1) | ||
Console.WriteLine ("Insufficient number of parameters"); | ||
else { | ||
string connectionString; | ||
string sql; | ||
IDbCommand command; | ||
IDbConnection db_connection; | ||
IDataReader reader; | ||
|
||
connectionString = "URI=file:" + args[0]; | ||
db_connection = (IDbConnection) new SqliteConnection(connectionString); | ||
db_connection.Open (); | ||
command = db_connection.CreateCommand (); | ||
sql = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"; | ||
command.CommandText = sql; | ||
reader = command.ExecuteReader (); | ||
while (reader.Read ()) { | ||
string TableName = reader.GetString (0); | ||
Console.WriteLine("Name: " + TableName); | ||
} | ||
|
||
// clean up | ||
reader.Close (); reader = null; | ||
command.Dispose (); command = null; | ||
db_connection.Close (); db_connection = null; | ||
|
||
Application.Init (false); | ||
|
||
Shell s = new Shell (); | ||
Application.Run (s); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
SOURCES = Autobahn.cs | ||
|
||
Autobahn.exe: $(SOURCES) Makefile | ||
gmcs -debug $(SOURCES) -pkg:mono-curses | ||
gmcs -debug $(SOURCES) -pkg:mono-curses -r:System.Data.dll -r:Mono.Data.SqliteClient.dll | ||
|
||
run: Autobahn.exe | ||
mono --debug Autobahn.exe; stty sane | ||
mono --debug Autobahn.exe urlclassifier3.sqlite; stty sane |