summaryrefslogtreecommitdiff
path: root/libopie2/opiedb/osqlitedriver.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiedb/osqlitedriver.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiedb/osqlitedriver.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp
index 6141504..47bc250 100644
--- a/libopie2/opiedb/osqlitedriver.cpp
+++ b/libopie2/opiedb/osqlitedriver.cpp
@@ -19,135 +19,138 @@
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "osqlquery.h"
#include "osqlitedriver.h"
#include <opie2/odebug.h>
#include <stdlib.h>
// fromLocal8Bit() does not work as expected. Thus it
// is replaced by fromLatin1() (eilers)
#define __BUGGY_LOCAL8BIT_
+using namespace Opie::DB;
+using namespace Opie::DB::Private;
+
namespace {
struct Query {
OSQLError::ValueList errors;
OSQLResultItem::ValueList items;
OSQLiteDriver *driver;
};
}
OSQLiteDriver::OSQLiteDriver( QLibrary *lib )
: OSQLDriver( lib )
{
m_sqlite = 0l;
}
OSQLiteDriver::~OSQLiteDriver() {
close();
}
QString OSQLiteDriver::id()const {
return QString::fromLatin1("SQLite");
}
void OSQLiteDriver::setUserName( const QString& ) {}
void OSQLiteDriver::setPassword( const QString& ) {}
void OSQLiteDriver::setUrl( const QString& url ) {
m_url = url;
}
void OSQLiteDriver::setOptions( const QStringList& ) {
}
/*
* try to open a db specified via setUrl
* and options
*/
bool OSQLiteDriver::open() {
char *error;
- odebug << "OSQLiteDriver::open: about to open" << oendl;
+ qDebug("OSQLiteDriver::open: about to open");
m_sqlite = sqlite_open(m_url.local8Bit(),
0,
&error );
/* failed to open */
if (m_sqlite == 0l ) {
// FIXME set the last error
- owarn << "OSQLiteDriver::open: " << error << oendl;
+ qWarning("OSQLiteDriver::open: %s", error );
free( error );
return false;
}
return true;
}
/* close the db
* sqlite closes them without
* telling failure or success
*/
bool OSQLiteDriver::close() {
if (m_sqlite )
sqlite_close( m_sqlite ), m_sqlite=0l;
return true;
}
/* Query */
OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
if ( !m_sqlite ) {
// FIXME set error code
OSQLResult result( OSQLResult::Failure );
return result;
}
Query query;
query.driver = this;
char *err;
/* SQLITE_OK 0 if return code > 0 == failure */
if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) {
- owarn << "OSQLiteDriver::query: Error while executing" << oendl;
+ qWarning("OSQLiteDriver::query: Error while executing");
free(err );
// FixMe Errors
}
OSQLResult result(OSQLResult::Success,
query.items,
query.errors );
return result;
}
OSQLTable::ValueList OSQLiteDriver::tables() const {
}
OSQLError OSQLiteDriver::lastError() {
OSQLError error;
return error;
};
/* handle a callback add the row to the global
* OSQLResultItem