Index: dbdataobject/dataobject.py
===================================================================
--- dbdataobject/dataobject.py	(revision 60)
+++ dbdataobject/dataobject.py	(working copy)
@@ -443,7 +443,7 @@
         """
         Compute a DELETE query
         """
-        query = 'DELETE %s.* FROM %s' % (self.__table_name, self.__table_name)
+        query = 'DELETE FROM %s' % (self.__table_name)
         args  = []
 
         # Joins
@@ -617,6 +617,11 @@
         Add a where clause
         If no where provided, clear the where clause
         """
+
+        # Connect to the database if needed
+        if not self.__connect():
+            return False
+
         if cond is not None:
             # To be able to substitute any args
             if self.__db.substr_format == '%s':
Index: dbdataobject/backends/sqlite3db.py
===================================================================
--- dbdataobject/backends/sqlite3db.py	(revision 0)
+++ dbdataobject/backends/sqlite3db.py	(revision 0)
@@ -0,0 +1,192 @@
+# Python DB DataObject : SQLite3 backend
+#
+# Copyright (C) 2007 Julien Danjou <julien@danjou.info>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+__author__  = "Julien Danjou <julien@danjou.info>"
+__cvsid__   = "$Id$"
+__version__ = "$Rev$"[11:-2]
+__all__     = [ "Database" ]
+
+from pysqlite2 import dbapi2 as sqlite
+
+import dbdataobject.errors as errors
+import common
+
+FIELD_TYPES = {
+        "INTEGER" : 'int',
+        "FLOAT"   : 'float',
+        "TEXT"    : 'str',
+        "BLOB"    : 'blob',
+        }
+
+class SQLite3Database(common.Database):
+
+    # Connection parameters
+    dsn_regexp      = 'sqlite3://(.*)'
+    connect_factory = sqlite.connect
+    connect_kwargs  = {}
+    substr_format   = '?'
+
+    def databaseStructure(self):
+        """
+        Returns the database structure
+        """
+
+        # Get the list of tables
+        result = self.query("""SELECT name FROM sqlite_master WHERE type='table' UNION ALL SELECT name FROM sqlite_temp_master WHERE type='table' ORDER BY name""")
+
+        if not result:
+            return result
+        
+        structure = {}
+        for row in self.cursor.fetchall():
+            structure[row[0]] = {}
+
+        # Get the list of fields
+        for table_name in structure.keys():
+            structure[table_name] = {}
+            structure[table_name]['primary_keys']    = []
+            structure[table_name]['primary_keys_ai'] = []
+            structure[table_name]['foreign_keys']    = []
+            structure[table_name]['keys']            = []
+            structure[table_name]['descriptions']    = {}
+
+            self.query('PRAGMA table_info(%s)' % (table_name))
+
+            for row in self.cursor.fetchall():
+
+                field_name = row[1]
+                if row[2]:
+                    field_type = FIELD_TYPES[row[2]]
+                else:
+                    field_type = FIELD_TYPES["TEXT"]
+            
+                # Keys
+                structure[table_name]['keys'].append(field_name)
+
+                # Primary keys
+                if row[5]:
+                    structure[table_name]['primary_keys'].append(field_name)
+
+                # Null
+                if row[3]:
+                    null = False
+                else:
+                    null = True
+
+                structure[table_name]['descriptions'][field_name] = (field_type, null)
+
+        return structure
+
+    def converter(self, value):
+        """
+        Convert a Python instance to an SQL representation
+        """
+        return converters.Instance2Str(value, converters.conversions)
+
+    def query(self, query, args=None):
+        """
+        Execute a query to the database
+        Returns the number of affected rows or false on failure
+        """
+        
+        if self.db == None:
+            return False
+
+        try:
+            print query
+            if args:
+                result = self.cursor.execute(query, args)
+            else:
+                result = self.cursor.execute(query)
+        except sqlite.Error, exception:
+            return errors.onRaise(self, exception)
+        
+        return result
+
+    def fetchone(self):
+        """
+        Fetch one row and returns the dictionnary representing the row
+        """
+
+        try:
+            result = self.cursor.fetchone()
+        except sqlite.Error, exception:
+            return errors.onRaise(self, exception)
+
+        # Database is not safe for queries while fetching a result
+        if result:
+            # Converting the result to dictionnary
+            result_dict = {}
+            for index, field_desc in enumerate(self.cursor.description):
+                result_dict[field_desc[0]] = result[index]
+            result = result_dict
+
+            self.is_safe = False
+
+        # Fetch is finished, database is now safe for queries
+        else:
+            self.is_safe = True
+
+        return result
+
+    def lastrowid(self):
+        """
+        Returns the id of the last inserted row
+        """
+        
+        try:
+            last_id = int(self.cursor.lastrowid)
+            # No autoincrement
+            if last_id == 0:
+                last_id = True
+        except:
+            last_id = True
+
+        return last_id
+
+    def autoCommit(self, autocommit):
+        """
+        Set the database in auto commit mode
+        """
+
+        if autocommit:
+            self.db.isolation_level = None
+
+        self.autocommit = autocommit
+
+        return True
+
+    def rollback(self):
+        """
+        Abort the current transaction
+        """
+
+        if self.opcount > 0:
+            self.opcount = 0
+            return self.db.rollback()
+
+        return True
+
+    def commit(self):
+        """
+        Commit the current transaction
+        """
+
+        return self.db.commit()
+
+Database = SQLite3Database

Property changes on: dbdataobject/backends/sqlite3db.py
___________________________________________________________________
Name: svn:keywords
   + "Author Date Id Rev URL"

Index: dbdataobject/backends/__init__.py
===================================================================
--- dbdataobject/backends/__init__.py	(revision 60)
+++ dbdataobject/backends/__init__.py	(working copy)
@@ -34,7 +34,7 @@
 # Available backends
 BACKENDS = {
   'mysql'  : ('MySQL',      'mysqldb'),
-  'sqlite' : ('SQLite',     'sqlitedb'),
+  'sqlite3' : ('SQLite3',     'sqlite3db'),
   'psql'   : ('PostgreSQL', 'postgresqldb'),
  }
 
