Advertisement
Guest User

myreader

a guest
Dec 15th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.53 KB | None | 0 0
  1. module sql.reader;
  2.  
  3. import etc.c.sqlite3;
  4. import std.typecons;
  5. import std.string : toStringz, fromStringz;
  6.  
  7. class Reader
  8. {
  9.     this(string dbFile)
  10.     {
  11.         int rc;
  12.        
  13.         rc = sqlite3_open(toStringz(dbFile), &db);
  14.         if(rc != SQLITE_OK) throw new Exception("Could not open database to read: " ~ dbFile);
  15.     }
  16.    
  17.     ~this()
  18.     {
  19.         if(db) close();
  20.     }
  21.    
  22.     void close()
  23.     {
  24.         sqlite3_close(db);
  25.     }
  26.    
  27.     private sqlite3* db;
  28.    
  29.     R[] readFullTable(R)(string tableName, int max)
  30.     if(isTuple!R)
  31.     {
  32.         auto rows = new R[5];
  33.         return rows;
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement