Author Topic: SQLite for C# ~ Gareth Isaac  (Read 14589 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: SQLite for C# ~ Gareth Isaac
« Reply #30 on: December 27, 2009, 06:49:25 AM »
write  100,000 records  8-)

Code: [Select]
[CommandMethod("addit")]
  public static void addit()
  {
   Editor ed = AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
   System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
   stopWatch.Start();

   string database = "C:\\MySQLite.db";
   using (ManagedSQLite.Database db = new ManagedSQLite.Database(database))
   {
    db.ExecuteDML("create table Test6(No int, Name char(64));");
    db.BeginTransaction();
    for (int i = 0; i < 100000; i++)
    {
     db.ExecuteDML(String.Format("insert into Test6 values ({0} , 'Welcome To TheSwamp');", i));
    }
    db.CommitTransaction();
   }

   stopWatch.Stop();
   TimeSpan ts = stopWatch.Elapsed;

   string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                      ts.Hours, ts.Minutes, ts.Seconds,
                                      ts.Milliseconds / 10);
   ed.WriteMessage("\n{0}", elapsedTime);
  }


00:00:01.91

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: SQLite for C# ~ Gareth Isaac
« Reply #31 on: December 27, 2009, 02:24:49 PM »

That's not too slothful Daniel.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: SQLite for C# ~ Gareth Isaac
« Reply #32 on: December 27, 2009, 05:57:59 PM »
 I think it's about done. Should I add a thread in the "Show your stuff"  area?, it might be easier to maintain there.
« Last Edit: December 29, 2009, 02:18:34 AM by Daniel »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: SQLite for C# ~ Gareth Isaac
« Reply #33 on: December 27, 2009, 06:16:54 PM »
Here is the latest build. I changed a few items internally. I think it's about done. Should I add a thread in the "Show your stuff"  area?, it might be easier to maintain there.

Sounds like a good plan :)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: SQLite for C# ~ Gareth Isaac
« Reply #34 on: December 28, 2009, 11:56:52 PM »
We have Docs.. almost done. BTY I am going to change blobs to byte arrays. instead of some pointer C# can't read 


Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: SQLite for C# ~ Gareth Isaac
« Reply #35 on: December 28, 2009, 11:58:59 PM »
bloody brilliant !!

Lorraine is packing the jellybeans and licorice as we speak  :D



added:
from memory, your significant other is a tax accountant ... make sure she puts aside the correct percentage   :angel:
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: SQLite for C# ~ Gareth Isaac
« Reply #36 on: December 29, 2009, 02:20:02 AM »
from memory, your significant other is a tax accountant ... make sure she puts aside the correct percentage   :angel:

HA! that would make her a Jelly Bean Counter  :lol:

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: SQLite for C# ~ Gareth Isaac
« Reply #37 on: December 29, 2009, 02:21:58 AM »
New build
Some documentation
added a Row class List<Object>  still need to override the ToString method
added a Table class List<Row> still need to override the ToString method
added a function Database.GetTable("query") that get a whole table in one call (list<list<object>>)  
I changed the blob to a System. Byte[]  I still need to test this.


edit go here http://www.theswamp.org/index.php?topic=31469.msg370071#new
« Last Edit: December 30, 2009, 03:26:03 AM by Daniel »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: SQLite for C# ~ Gareth Isaac
« Reply #38 on: December 30, 2009, 02:50:39 AM »
I added a function to return a DataTable from a query.   8-)

Code: [Select]
namespace SQLiteNetSample
{
 public partial class DataGrid : Form
 {
  public DataGrid()
  {
   InitializeComponent();
   BindingSource src = new BindingSource();
   src.DataSource = getTable();
   this.dataGridView1.DataSource = src;
  }

  //
  DataTable getTable()
  {
   using(SQLiteNET.Database db = new SQLiteNET.Database("C:\\Northwind.db"))
   {
    return db.GetDataTable("SELECT * FROM Customers");
   }
  }

 }
}


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: SQLite for C# ~ Gareth Isaac
« Reply #39 on: December 30, 2009, 03:26:50 AM »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: SQLite for C# ~ Gareth Isaac
« Reply #40 on: December 30, 2009, 03:27:58 AM »
Restarting over here   http://www.theswamp.org/index.php?topic=31469.msg370071#new

Just saw that.
Thanks for the effort Daniel.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.