# 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`

  Bases: `object`

class `sqlobject.main.``SQLObject`(**kw)

  Bases: `object`

  `SelectResultsClass`

    alias of `SelectResults`

  `childName` = None
  classmethod `clearTable`(connection=None, clearJoinTables=True)
  classmethod `coerceID`(value)
  classmethod `createIndexes`(ifNotExists=False, connection=None)
  classmethod `createIndexesSQL`(connection=None)
  classmethod `createJoinTables`(ifNotExists=False, connection=None)
  classmethod `createJoinTablesSQL`(connection=None)
  classmethod `createTable`(ifNotExists=False, createJoinTables=True, createIndexes=True, applyConstraints=True, connection=None)
  classmethod `createTableSQL`(createJoinTables=True, createIndexes=True, connection=None)
  classmethod `delete`(id, connection=None)
  classmethod `deleteBy`(connection=None, **kw)
  classmethod `deleteMany`(where=<class 'sqlobject.sqlbuilder.NoDefault'>, connection=None)
  `destroySelf`()
  classmethod `dropJoinTables`(ifExists=False, connection=None)
  classmethod `dropTable`(ifExists=False, dropJoinTables=True, cascade=False, connection=None)
  `expire`()
  classmethod `get`(id, connection=None, selectResults=None)
  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)
  classmethod `selectBy`(connection=None, **kw)
  `set`(_suppress_set_sig=False, **kw)
  classmethod `setConnection`(value)
  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`(sqlmeta, connection=None)
    classmethod `addIndex`(indexDef)
    classmethod `addJoin`(joinDef)
    `asDict`()

      Return the object as a dictionary of columns to values.

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

      Expire all instances of this class.

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

      alias of `int`

    `indexDefinitions` = []
    `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)
  `sync`()
  `syncUpdate`()
  classmethod `tableExists`(connection=None)
  `tablesUsedImmediate`()

exception `sqlobject.main.``SQLObjectIntegrityError`

  Bases: `Exception`

exception `sqlobject.main.``SQLObjectNotFound`

  Bases: `LookupError`

`sqlobject.main.``getID`(obj, refColumn=None)

`sqlobject.main.``getObject`(obj, klass)

`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)

  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`(sqlmeta, connection=None)
  classmethod `addIndex`(indexDef)
  classmethod `addJoin`(joinDef)
  `asDict`()

    Return the object as a dictionary of columns to values.

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

    Expire all instances of this class.

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

    alias of `int`

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