Skip to content

Commit

Permalink
Get sqlite database filename from user and find tables in that.
Browse files Browse the repository at this point in the history
  • Loading branch information
psankar committed Dec 21, 2010
1 parent f6d063a commit fb31396
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
42 changes: 34 additions & 8 deletions Autobahn.cs
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);
}
}
}
}
4 changes: 2 additions & 2 deletions Makefile
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

0 comments on commit fb31396

Please sign in to comment.