Package orm2 :: Module datasource
[hide private]
[frames] | no frames]

Module datasource

source code

Classes [hide private]
  datasource_base
The DataSource encapsulates the functionality we need to talk to the database.

Functions [hide private]
  datasource(connection_string="", **kwargs)
Return a ORM datasource object constructed from a connection string or a number of keyword arguments.

Function Details [hide private]

datasource(connection_string="", **kwargs)

source code 

Return a ORM datasource object constructed from a connection string or a number of keyword arguments.

The connection strings follow the conventions for PostgreSQL DSNs: they consist of keyword=value pairs seperated with whitespace. Keywords recognized are:
 adapter  - name of the ORM adapter used. Use the name from the
            adapters/ directory.
 db       - name of the database to connect to
 user     - Database username
 password - Password used for authentication
 host     - hostname or IP address of the machine the database
            runs on (note that there might be a difference if you
            use 127.0.0.1 or localhost. The first creating a tcp/ip
            connection, the latter a unix/fifo connection. This is
            true for at leas pgsql and mysql
 debug    - if set SQL queries will be printed to stdout (actually
            the debug.debug function is called so you can overload
            it)

Each of the database backends may define its own keywords. For instance PostgreSQL will understand each of the original keywords as aliases. Check the documentation!

Values may not contain spaces.

If you prefer to use the keyword argument syntax, the paramters must be the key and their arguments the values:
  datasource('db=test user=diedrich password=kfjdh')
equals:
  datasource(db='test', user='diedrich', password='kfjdh')