Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Sqlite;
- class PkgDB : GLib.Object {
- private Database db;
- private Statement stmt;
- public PkgDB( string filename ) {
- Database.open_v2( filename, out this.db, OPEN_READWRITE );
- }
- public void change_pkg( string name, string version, string column, string newentry ) {
- this.db.prepare_v2(@"update tbl set $column = '$newentry' where name = '$name' and version = '$version'",
- -1, out this.stmt, null);
- this.stmt.step();
- }
- public void add_pkg( string installed, string name, string version, string description, string dependencies ) {
- this.db.prepare_v2(@"insert into tbl VALUES('$installed', '$name', '$version', '$description', '$dependencies')",
- -1, out this.stmt, null);
- this.stmt.step();
- }
- public void remove_pkg( string name, string version ) {
- this.db.prepare_v2(@"delete from tbl where name = '$name' and version = '$version'", -1, out this.stmt, null);
- this.stmt.step();
- }
- public void print_pkg( string name, string version ) {
- this.db.prepare_v2(@"select * from tbl where name = '$name' and version = '$version'", -1, out this.stmt, null);
- this.stmt.step();
- for (int place = 0; place < 5; place ++ ) {
- string tstring = this.stmt.column_text(place);
- stdout.printf("%s\n", tstring);
- }
- }
- }
Add Comment
Please, Sign In to add comment