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

Class datasource

source code

        sql.datasource --+    
                         |    
datasource.datasource_base --+
                             |
                            datasource
Known Subclasses:
zpsycopg_db_conn

Instance Methods [hide private]
  __init__(self, dsn=None)
DSN - PostgreSLQ dsn it's basically a string like 'field1=value field2=value' fields are describe below (from the pgsql Programmer's Manual):
  _from_params(params)
A pgsql connection string may contain all the standard ORM keywords plus all of those described above in the __init__ method's doc
  _from_connection(conn)
  check_cast_handler(self, datatype_class, relation, column)
For each of the custom types register the built-in str class as the psycopg cast class so the SQL literal the pgsql backend returns can be parsed into an appropriate Python datastucture by our datatype and column class
  dsn(self)
Return the DSN this datasource has been initialized with.
  execute(self, query, modify=False)
Run a query on the database connection.
  connect(self)
  backend_version(self)
  backend_encoding(self)
  select_after_insert_where(self, dbobj)

Inherited from datasource.datasource_base: close, commit, count, cursor, delete_by_primary_key, flush_updates, insert, join_select, primary_key_where, query_one, rollback, run_select, select, select_after_insert, select_by_primary_key, select_for_update, select_one, update, update_cursor

Inherited from datasource.datasource_base (private): _dbconn

Inherited from sql.datasource: escape_string, identifyer_quotes, string_quotes


Static Methods [hide private]
  from_params(params)
A pgsql connection string may contain all the standard ORM keywords plus all of those described above in the __init__ method's doc
  from_connection(conn)

Class Variables [hide private]
  escaped_chars = [('\\', '\\\\\\\\'), ("'", "\\'"), ('"', '\\"'), ('\...
  _dbfailures = 0
  _ERRORS_BEFORE_RECONNECT = 50
  encodings = {'EUC_CN': '?', 'TCVN': '?', 'WIN874': '?', 'ISO_885...

Inherited from datasource.datasource_base (private): _format_funcs


Method Details [hide private]

__init__(self, dsn=None)
(Constructor)

source code 
DSN - PostgreSLQ dsn it's basically a string like 'field1=value field2=value' fields are describe below (from the pgsql Programmer's Manual):

host

Name of host to connect to. If this begins with a slash, it specifies Unix-domain communication rather than TCP/IP communication; the value bis the name of the directory in which the socket file is stored. The default is to connect to a Unix-domain socket in /tmp. hostaddr

IP address of host to connect to. This should be in standard numbers-and-dots form, as used by the BSD functions inet_aton et al. If a nonzero-length string is specified, TCP/IP communication is used.

Using hostaddr instead of host allows the application to avoid a host name look-up, which may be important in applications with time constraints. However, Kerberos authentication requires the host name. The following therefore applies. If host is specified without hostaddr, a host name lookup is forced. If hostaddr is specified without host, the value for hostaddr gives the remote address; if Kerberos is used, this causes a reverse name query. If both host and hostaddr are specified, the value for hostaddr gives the remote address; the value for host is ignored, unless Kerberos is used, in which case that value is used for Kerberos authentication. Note that authentication is likely to fail if libpq is passed a host name that is not the name of the machine at hostaddr.

Without either a host name or host address, libpq will connect using a local Unix domain socket. port

Port number to connect to at the server host, or socket file name extension for Unix-domain connections.

dbname

The database name.

user

User name to connect as.

password

Password to be used if the server demands password authentication.

options

Trace/debug options to be sent to the server.

tty

A file or tty for optional debug output from the backend.

requiressl

Set to 1 to require SSL connection to the backend. Libpq will then refuse to connect if the server does not support SSL. Set to 0 (default) to negotiate with server. example= 'host=localhost dbname=test user=test'
Overrides: datasource.datasource_base.__init__

_from_params(params)

source code 
A pgsql connection string may contain all the standard ORM keywords plus all of those described above in the __init__ method's doc

from_params(params)
Static Method

source code 
A pgsql connection string may contain all the standard ORM keywords plus all of those described above in the __init__ method's doc

_from_connection(conn)

source code 
None

from_connection(conn)
Static Method

source code 
None

check_cast_handler(self, datatype_class, relation, column)

source code 
For each of the custom types register the built-in str class as the psycopg cast class so the SQL literal the pgsql backend returns can be parsed into an appropriate Python datastucture by our datatype and column class

dsn(self)

source code 
Return the DSN this datasource has been initialized with.

execute(self, query, modify=False)

source code 

Run a query on the database connection.

This function also performs failure accounting and will re-connect to the database if a certain threshold has passed.
Overrides: datasource.datasource_base.execute

connect(self)

source code 
None

backend_version(self)

source code 
None

backend_encoding(self)

source code 
None
Overrides: sql.datasource.backend_encoding

select_after_insert_where(self, dbobj)

source code 
None
Overrides: datasource.datasource_base.select_after_insert_where

Class Variable Details [hide private]

escaped_chars

None
Value:
[('\\', '\\\\\\\\'),
 ("'", "\\'"),
 ('"', '\\"'),
 ('\x00', '\\\\000'),
 ('`', '\\`'),
 ('\xc2\xb4', '\\\xc2\xb4'),
 ('\n', '\\n'),
 ('\r', '\\r'),
...                                                                    
      

_dbfailures

None
Value:
0                                                                     
      

_ERRORS_BEFORE_RECONNECT

None
Value:
50                                                                    
      

encodings

None
Value:
{'ALT': '?',
 'EUC_CN': '?',
 'EUC_JP': '?',
 'EUC_KR': '?',
 'EUC_TW': '?',
 'ISO_8859_5': 'iso-8859-5',
 'ISO_8859_6': 'iso-8859-6',
 'ISO_8859_7': 'iso-8859-7',
...