]> granicus.if.org Git - pdns/commitdiff
teach SSQLite3 class to also be able to generate a new sqlite3 database if so requested
authorBert Hubert <bert.hubert@netherlabs.nl>
Sun, 4 Mar 2012 11:12:24 +0000 (11:12 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sun, 4 Mar 2012 11:12:24 +0000 (11:12 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2449 d19b8d6e-7fed-0310-83ef-9ca221ded41b

modules/gsqlite3backend/ssqlite3.cc
modules/gsqlite3backend/ssqlite3.hh

index c59e996e6e3cfe2e6678f3fc63e8d73fd615c222..a033f8384f680b6f1da7677418cd844d610ec3bd 100644 (file)
 #endif // Unix
 
 // Constructor.
-SSQLite3::SSQLite3( const std::string & database )
+SSQLite3::SSQLite3( const std::string & database, bool creat )
 {
   // Open the database connection.
-  if ( access( database.c_str(), F_OK ) == -1 )
-    throw sPerrorException( "SQLite database does not exist yet" );
+  if(!creat) 
+    if ( access( database.c_str(), F_OK ) == -1 )
+      throw sPerrorException( "SQLite database does not exist yet" );
 
   if ( sqlite3_open( database.c_str(), &m_pDB)!=SQLITE_OK )
     throw sPerrorException( "Could not connect to the SQLite database '" + database + "'" );
index d7539dcfa1dd7553c370dead5c010c0956cdc51e..7b3c3cf1126768449b478351b918b370da790c78 100644 (file)
@@ -23,7 +23,7 @@ private:
 protected:
 public:
   //! Constructor.
-  SSQLite3( const std::string & database );
+  SSQLite3( const std::string & database, bool creat=false );
 
   //! Destructor.
   ~SSQLite3();