New API reference documentation is available for testing at http://thewinecellarbook.com/daboDocTestAlt/. Please report any problems or suggestions on the dabo-users mailing list.

Class SQLite

Class providing SQLite connectivity. Uses sqlite3 or pysqlite2 package.

Properties

Application BaseClass BasePrefKey
Class Encoding KeepAliveInterval
LogEvents Name Parent
PreferenceManager

Events


Methods

addField addFrom addGroupBy
addJoin addOrderBy addWhere
afterInit autoBindEvents beforeInit
beginTransaction bindEvent bindEvents
commitTransaction createJustIndexes createJustTable
createTableAndIndexes encloseNames escQuote
flush formSQL formatBLOB
formatDateTime formatForQuery formatJoinType
formatNone getAbsoluteName getConnection
getCursor getDaboFieldType getDescription
getDictCursorClass getFieldInfoFromDescription getFields
getLastInsertID getLimitWord getProperties
getStructureDescription getTableRecordCount getTables
getUpdateTablePrefix getWhereTablePrefix getWordMatchFormat
initEvents initProperties isExistingTable
isValidModule massageDescription noResultsOnDelete
noResultsOnSave pregenPK prepareWhere
processFields raiseEvent rollbackTransaction
setChildFilterClause setFieldClause setFromClause
setGroupByClause setJoinClause setNonUpdateFields
setOrderByClause setProperties setPropertiesFromAtts
setSQL setWhereClause unbindEvent




Properties

Application
Read-only object reference to the Dabo Application object.  (dApp).

(inherited from dObject)
BaseClass
The base Dabo class of the object. Read-only.  (class)

(inherited from dObject)
BasePrefKey
Base key used when saving/restoring preferences  (str)

(inherited from dObject)
Class
The class the object is based on. Read-only.  (class)

(inherited from dObject)
Encoding
Backend encoding  (str)

(inherited from dBackend)
KeepAliveInterval
Specifies how often a KeepAlive query should be sent to the server.

Defaults to None, meaning we never send a KeepAlive query. The interval
is expressed in seconds.

(inherited from dBackend)
LogEvents
Specifies which events to log.  (list of strings)

If the first element is 'All', all events except the following listed events
will be logged.
Event logging is resource-intensive, so in addition to setting this LogEvents
property, you also need to make the following call:

	>>> dabo.eventLogging = True


(inherited from dObject)
Name
The name of the object.  (str)

(inherited from dObject)
Parent
The containing object.  (obj)

(inherited from dObject)
PreferenceManager
Reference to the Preference Management object  (dPref)

(inherited from dObject)



Events




Methods

addField(self, clause, exp, alias=None, autoQuote=True)
Add a field to the field clause.

(inherited from dBackend)
addFrom(self, clause, exp, alias=None, autoQuote=True)
Add a table to the sql statement.

(inherited from dBackend)
addGroupBy(self, clause, exp, autoQuote=True)
Add an expression to the group-by clause.

(inherited from dBackend)
addJoin(self, tbl, joinCondition, exp, joinType=None, autoQuote=True)
Add a joined table to the sql statement.

(inherited from dBackend)
addOrderBy(self, clause, exp, autoQuote=True)
Add an expression to the order-by clause.

(inherited from dBackend)
addWhere(self, clause, exp, comp='and', autoQuote=True)
Add an expression to the where clause.

(inherited from dBackend)
afterInit(self)
Subclass hook. Called after the object's __init__ has run fully.
Subclasses should place their __init__ code here in this hook, instead of
overriding __init__ directly, to avoid conflicting with base Dabo behavior.

(inherited from dObject)
autoBindEvents(self, force=True)
Automatically bind any on*() methods to the associated event.

User code only needs to define the callback, and Dabo will automatically
set up the event binding. This will satisfy lots of common cases where
you want an object or its parent to respond to the object's events.

To use this feature, just define a method on<EventName>(), or	if you
want a parent container to respond to the event, make a method in the
parent on<EventName>_<object Name or RegID>().

For example::
	
	class MyButton(dabo.ui.dButton):
		def onHit(self, evt):
			print "Hit!"

	class MyPanel(dabo.ui.dPanel):
		def afterInit(self):
			self.addObject(MyButton, RegID="btn1")

		def onHit_btn1(self, evt):
			print "panel: button hit!"

When the button is pressed, you'll see both 'hit' messages because of
auto event binding.

If you want to bind your events explicitly, you can turn off auto event
binding by calling::

	 dabo.autoBindEvents = False

This feature is inspired by PythonCard.

(inherited from EventMixin)
beforeInit(self, *args, **kwargs)
Subclass hook. Called before the object is fully instantiated.
Usually, user code should override afterInit() instead, but there may be
cases where you need to set an attribute before the init stage is fully
underway.

(inherited from dObject)
beginTransaction(self, cursor)
Begin a SQL transaction. Since pysqlite does an implicit
'begin' all the time, simply do nothing.
bindEvent(self, eventClass, function, _auto=False)
Bind a dEvent to a callback function.

(inherited from EventMixin)
bindEvents(self, bindings)
Bind a sequence of [dEvent, callback] lists.

(inherited from EventMixin)
commitTransaction(self, cursor)
Commit a SQL transaction.
createJustIndexes(self, tabledef, cursor)

			
(inherited from dBackend)
createJustTable(self, tabledef, cursor)

			
(inherited from dBackend)
createTableAndIndexes(self, tabledef, cursor, createTable=True, createIndexes=True)

			
		
encloseNames(self, exp, autoQuote=True, keywords=None)
When table/field names contain spaces, this will safely enclose them
in quotes or whatever delimiter is appropriate for the backend, unless
autoQuote is False, in which case it leaves things untouched. If there are
keywords that are part of the expression that should not be enclosed
within the field name, pass them as a tuple to the keywords parameter.

(inherited from dBackend)
escQuote(self, val)

			
		
flush(self, crs)

			
		
formSQL(self, fieldClause, fromClause, joinClause, whereClause, groupByClause, orderByClause, limitClause)
Creates the appropriate SQL for the backend, given all
the required clauses. Some backends order these differently, so
they should override this method with their own ordering.

(inherited from dBackend)
formatBLOB(self, val)

			
		
formatDateTime(self, val)
We need to wrap the value in quotes.
formatForQuery(self, val, fieldType=None)

			
		
formatJoinType(self, jt)
Default formatting for jointype keywords. Override in subclasses if needed.

(inherited from dBackend)
formatNone(self)
Properly format a None value to be included in an update statement.

Each backend should override as needed. The default is to return "NULL".

(inherited from dBackend)
getAbsoluteName(self)
Return the fully qualified name of the object.

(inherited from dObject)
getConnection(self, connectInfo, forceCreate=False, **kwargs)

			
		
getCursor(self, cursorClass)
override in subclasses if necessary

(inherited from dBackend)
getDaboFieldType(self, backendFieldType)
Return the Dabo code (I, T, D, ...) for the passed backend Field Type.

If it can't be determined, the field type will be '?'.

(inherited from dBackend)
getDescription(self, cursor)
Normally, cursors should always be able to report their
description properly. However, some backends such as
SQLite will not report a description if there is no data in the
record set. This method provides a way for those backends
to deal with this. By default, though, just return the contents
of the description attribute.

(inherited from dBackend)
getDictCursorClass(self)

			
		
getFieldInfoFromDescription(self, cursorDescription)
Return field information from the cursor description.

(inherited from dBackend)
getFields(self, tableName, cursor)

			
		
getLastInsertID(self, cursor)
Return the ID of the last inserted row, or None.

When inserting a new record in a table that auto-generates a PK
value, different databases have their own way of retrieving that value.
This method should be coded in backend-specific subclasses to address
that database's approach.

(inherited from dBackend)
getLimitWord(self)
Return the word to use in the db-specific limit clause.
Override for backends that don't use the word 'limit'

(inherited from dBackend)
getProperties(self, propertySequence=(), propsToSkip=(), ignoreErrors=False, *propertyArguments)
Returns a dictionary of property name/value pairs.

If a sequence of properties is passed, just those property values
will be returned. Otherwise, all property values will be returned.
The sequence of properties can be a list, tuple, or plain string
positional arguments. For instance, all of the following are
equivilent::

	print self.getProperties("Caption", "FontInfo", "Form")
	print self.getProperties(["Caption", "FontInfo", "Form"])
	t = ("Caption", "FontInfo", "Form")
	print self.getProperties(t)
	print self.getProperties(\*t)

An exception will be raised if any passed property names don't
exist, aren't actual properties, or are not readable (do not have
getter functions).

However, if an exception is raised from the property getter function,
the exception will get caught and used as the property value in the
returned property dictionary. This allows the property list to be
returned even if some properties can't be evaluated correctly by the
object yet.

(inherited from PropertyHelperMixin)
getStructureDescription(self, cursor)
Return the basic field structure.

(inherited from dBackend)
getTableRecordCount(self, tableName, cursor)

			
		
getTables(self, cursor, includeSystemTables=False)

			
		
getUpdateTablePrefix(self, table, autoQuote=True)
Table name prefixes are not allowed.
getWhereTablePrefix(self, table, autoQuote=True)
Table name prefixes are not allowed.
getWordMatchFormat(self)
By default, will return the standard format for an
equality test. If search by words is available, the format
must be implemented in each specific backend.

The format must have the expressions %(table)s, %(field)s,
and %(value)s, which will be replaced with the table, field,
and value strings, respectively.

(inherited from dBackend)
initEvents(self)
Hook for subclasses. User code should do custom event binding
here, such as::
	
	self.bindEvent(dEvents.GotFocus, self.customGotFocusHandler)
	

(inherited from dObject)
initProperties(self)
Hook for subclasses. User subclasses should set properties
here, such as::
	
	self.Name = "MyTextBox"
	self.BackColor = (192,192,192)
	

(inherited from dObject)
isExistingTable(self, table)
Returns whether or not the table exists.

(inherited from dBackend)
isValidModule(self)
Test the dbapi to see if it is supported on this computer.

(inherited from dBackend)
massageDescription(self, cursor)
Some dbapi programs do strange things to the description.
In particular, kinterbasdb forces the field names to upper case
if the field statement in the SQL that was executed contains an
'as' expression.

This is called after every execute() by the cursor, since the
description field is updated each time. By default, we simply
copy it to the 'descriptionClean' attribute.

(inherited from dBackend)
noResultsOnDelete(self)
Most backends will return a non-zero number if there are deletions.
Some do not, so this will have to be customized in those cases.

(inherited from dBackend)
noResultsOnSave(self)
SQLite does not return anything on a successful update
pregenPK(self, cursor)
In the case where the database requires that PKs be generated
before an insert, this method provides a backend-specific
means of accomplishing this. By default, we return None.

(inherited from dBackend)
prepareWhere(self, clause, autoQuote=True)
Normally, just return the original. Can be overridden as needed
for specific backends.

(inherited from dBackend)
processFields(self, txt)
Default is to return the string unchanged. Override
in cases where the str needs processing.

(inherited from dBackend)
raiseEvent(self, eventClass, uiEvent=None, *args, **kwargs)
Send the event to all registered listeners.

If uiEvent is sent, dEvents.Event will be able to parse it for useful
information to send along to the callback. 

Additional arguments, if any, are sent along to the constructor	of the
event. While this feature exists so that UI-lib event handlers can pass
along information (such as the keystroke information in a key event), user
code may pass along additional arguments as well, which	will exist in the
event.EventData dictionary property.

In most cases, user code should call raiseEvent() with
the event class (dEvents.Hit, for example) as the only parameter.

(inherited from EventMixin)
rollbackTransaction(self, cursor)
Rollback a SQL transaction.
setChildFilterClause(self, clause, autoQuote=True)

			
(inherited from dBackend)
setFieldClause(self, clause, autoQuote=True)

			
(inherited from dBackend)
setFromClause(self, clause, autoQuote=True)

			
(inherited from dBackend)
setGroupByClause(self, clause, autoQuote=True)

			
(inherited from dBackend)
setJoinClause(self, clause, autoQuote=True)

			
(inherited from dBackend)
setNonUpdateFields(self, cursor)

			
		
setOrderByClause(self, clause, autoQuote=True)

			
(inherited from dBackend)
setProperties(self, propDict={}, ignoreErrors=False, **propKw)
Sets a group of properties on the object all at once.

You have the following options for sending the properties:
	
	1) Property/Value pair dictionary
	2) Keyword arguments
	3) Both

The following examples all do the same thing::

	self.setProperties(FontBold=True, ForeColor="Red")
	self.setProperties({"FontBold": True, "ForeColor": "Red"})
	self.setProperties({"FontBold": True}, ForeColor="Red")


(inherited from PropertyHelperMixin)
setPropertiesFromAtts(self, propDict={}, ignoreExtra=True, context=None)
Sets a group of properties on the object all at once. This
is different from the regular setProperties() method because
it only accepts a dict containing prop:value pairs, and it
assumes that the value is always a string. It will convert
the value to the correct type for the property, and then set
the property to that converted value. If the value needs to be evaluated
in a specific namespace, pass that as the 'context' parameter.

(inherited from PropertyHelperMixin)
setSQL(self, sql)

			
(inherited from dBackend)
setWhereClause(self, clause, autoQuote=True)

			
(inherited from dBackend)
unbindEvent(self, eventClass=None, function=None)
Remove a previously registered event binding.

Removes all registrations that exist for the given binding for this
object. If event is None, all bindings for the passed function are
removed. If function is None, all bindings for the passed event are
removed. If both event and function are None, all event bindings are
removed.

(inherited from EventMixin)

Dabo 0.9.4 (rev. 7089)
9 Feb 2012 23:31:09