Guest User

Untitled

a guest
Apr 22nd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 1.12 KB | None | 0 0
  1. using Sqlite;
  2.  
  3. class DB : GLib.Object {
  4.  private Database db;
  5.  private Statement stmt;
  6.  
  7.  public PkgDB( string filename ) {
  8.   Database.open_v2( string filename, out this.db, OPEN_READWRITE);
  9.  }
  10.  
  11.  public void rm_entry(string name, string ver) {
  12.   this.db.prepare_v2(@"delete from pkgs where name = '$name' and version = '$ver'",
  13.                      -1, out this.stmt, null);
  14.   this.stmt.step();
  15.  }
  16.  
  17.  public void ad_entry(string inst, string name, string ver, string desc, string deps) {
  18.   this.db.prepare_v2(@"insert into pkgs VALUES('$inst', '$name', '$ver', '$desc', 'deps')",
  19.                      -1, out this.stmt, null);
  20.   this.stmt.step();
  21.  }
  22.  
  23.  public void ch_entry(string name, string ver, string col, string newval) {
  24.   this.db.prepare_v2(@"update pkgs set $col = '$newval' where name = '$name' and version = '$ver'",
  25.                      -1, out this.stmt, null);
  26.   this.stmt.step();
  27.  }
  28.  
  29.  public void inf_entry(string name, string ver) {
  30.   this.db.prepare_v2(@"select $col from pkgs where name = '$name' and version = '$ver'", -1,
  31.                      out this.stmt, null);
  32.   this.stmt.step();
  33.  
  34.  }
Add Comment
Please, Sign In to add comment