sqlobject.main module

SQLObject

author:Ian Bicking <ianb@colorstudy.com>

SQLObject is a object-relational mapper. See SQLObject.html or SQLObject.rst for more.

With the help by Oleg Broytman and many other contributors. See Authors.rst.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 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 Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

class sqlobject.main.NoDefault[source]
class sqlobject.main.SQLObject(**kw)[source]

Bases: object

SelectResultsClass

alias of sqlobject.sresults.SelectResults

childName = None
classmethod clearTable(connection=None, clearJoinTables=True)[source]
classmethod coerceID(value)[source]
classmethod createIndexes(ifNotExists=False, connection=None)[source]
classmethod createIndexesSQL(connection=None)[source]
classmethod createJoinTables(ifNotExists=False, connection=None)[source]
classmethod createJoinTablesSQL(connection=None)[source]
classmethod createTable(ifNotExists=False, createJoinTables=True, createIndexes=True, applyConstraints=True, connection=None)[source]
classmethod createTableSQL(createJoinTables=True, createIndexes=True, connection=None)[source]
classmethod delete(id, connection=None)[source]
classmethod deleteBy(connection=None, **kw)[source]
classmethod deleteMany(where=<class sqlobject.sqlbuilder.NoDefault>, connection=None)[source]
destroySelf()[source]
classmethod dropJoinTables(ifExists=False, connection=None)[source]
classmethod dropTable(ifExists=False, dropJoinTables=True, cascade=False, connection=None)[source]
expire()[source]
classmethod get(id, connection=None, selectResults=None)[source]
classmethod select(clause=None, clauseTables=None, orderBy=<class sqlobject.sqlbuilder.NoDefault>, limit=None, lazyColumns=False, reversed=False, distinct=False, connection=None, join=None, forUpdate=False)[source]
classmethod selectBy(connection=None, **kw)[source]
set(_suppress_set_sig=False, **kw)[source]
classmethod setConnection(value)[source]
class sqlmeta(instance)

Bases: object

This object is the object we use to keep track of all sorts of information. Subclasses are made for each SQLObject subclass (dynamically if necessary), and instances are created to go alongside every SQLObject instance.

classmethod addColumn(columnDef, changeSchema=False, connection=None)
classmethod addColumnsFromDatabase(connection=None)
classmethod addIndex(indexDef)
classmethod addJoin(joinDef)
asDict()

Return the object as a dictionary of columns to values.

cacheValues = True
childClasses = {}
childName = None
dbEncoding = None
defaultOrder = None
classmethod delColumn(column, changeSchema=False, connection=None)
classmethod delJoin(joinDef)
dirty = False
classmethod expireAll(connection=None)

Expire all instances of this class.

expired = False
fromDatabase = False
classmethod getColumns()
idName = None
idSequence = None
idSize = None
idType

alias of __builtin__.int

indexes = []
joinDefinitions = []
joins = []
lazyUpdate = False
parentClass = None
registry = None
classmethod send(signal, *args, **kw)
classmethod setClass(soClass)
style = None
table = None
classmethod sqlrepr(value, connection=None)[source]
sync()[source]
syncUpdate()[source]
classmethod tableExists(connection=None)[source]
tablesUsedImmediate()[source]
exception sqlobject.main.SQLObjectIntegrityError[source]

Bases: exceptions.Exception

exception sqlobject.main.SQLObjectNotFound[source]

Bases: exceptions.LookupError

sqlobject.main.getID(obj, refColumn=None)[source]
sqlobject.main.getObject(obj, klass)[source]
sqlobject.main.sqlhub

This object serves as a hub for connections, so that you can pass in a ConnectionHub to a SQLObject subclass as though it was a connection, but actually bind a real database connection later. You can also bind connections on a per-thread basis.

You must hang onto the original ConnectionHub instance, as you cannot retrieve it again from the class or instance.

To use the hub, do something like:

hub = ConnectionHub()
class MyClass(SQLObject):
    _connection = hub

hub.threadConnection = connectionFromURI('...')
class sqlobject.main.sqlmeta(instance)[source]

Bases: object

This object is the object we use to keep track of all sorts of information. Subclasses are made for each SQLObject subclass (dynamically if necessary), and instances are created to go alongside every SQLObject instance.

classmethod addColumn(columnDef, changeSchema=False, connection=None)[source]
classmethod addColumnsFromDatabase(connection=None)[source]
classmethod addIndex(indexDef)[source]
classmethod addJoin(joinDef)[source]
asDict()[source]

Return the object as a dictionary of columns to values.

cacheValues = True
childClasses = {}
childName = None
dbEncoding = None
defaultOrder = None
classmethod delColumn(column, changeSchema=False, connection=None)[source]
classmethod delJoin(joinDef)[source]
dirty = False
classmethod expireAll(connection=None)[source]

Expire all instances of this class.

expired = False
fromDatabase = False
classmethod getColumns()[source]
idName = None
idSequence = None
idSize = None
idType

alias of __builtin__.int

indexes = []
joinDefinitions = []
joins = []
lazyUpdate = False
parentClass = None
registry = None
classmethod send(signal, *args, **kw)[source]
classmethod setClass(soClass)[source]
style = None
table = None