| |
- SQLQuery(Propertied)
-
- AttrNamesFromNumbers
- AttributeDefaultValue
- AttributeNumbers
- ForeignConstraints
- ListDatabases
- ListDatatypes
- ListIndices
- ListTables
- TableStructure
class AttrNamesFromNumbers(SQLQuery) |
|
Get attr names from table-oid and set of attr indices |
|
- Method resolution order:
- AttrNamesFromNumbers
- SQLQuery
- Propertied
- object
Methods defined here:
- processResults(self, cursor, **named)
Data and other attributes defined here:
- sql = '\n\t\tSELECT\n\t\t\ta.adnum,\n\t\t\ta.adsrc\n\t\tFROM\n\t\t\tpg_at...\tc.oid = a.adrelid AND\n\t\t\ta.attnum IN %%(set)s;\n\t'
Methods inherited from SQLQuery:
- __call__(self, cursor, **namedarguments)
- Execute with cursor
cursor -- the pytable.dbcursor object to be
used for executing the query. Note that the
query will attempt to automatically coerce a
dbdriver or dbconnection object to a cursor
using that driver/connection. A log warning
will be returned if passing a driver (which
is not recommended, as it will result in
significant setup overhead (connections are
expensive to create for a single execution)).
namedarguments -- will be substituted using
python string substitution into the template
query string in order to create the final
query string. For single-execution queries
(SQLQuery), the namedarguments also represent
the row from which query arguments will be
taken. For multiple-execution queries
(SQLMultiQuery), the namedargument "dataSet"
is used as the executemany argument.
The "do" method takes care of the actual execution
of the query after cursor-coercion and query
substitution.
The "processResults" method takes the cursor and
returns the final result-set for the query which
will be the value returned from this function.
By default, this is simply a pointer to the cursor
used to execute the query.
- __init__(self, sql=None, debug=None, **named)
- Initialise the SQLQuery
sql -- sql string or None to use class' sql value
debug -- if provided (not None), override class' debug flag
- do(self, cursor, query, **namedarguments)
- Do the actual processing of the query (execute)
cursor -- a dbcursor object
query -- a final SQL query string, must be fully
substituted so that decree will operate properly
with the given cursor.
namedarguments -- for the single-query version,
(SQLQuery, this version), used as the dictionary
source for named and pyformat query arguments.
These are the same arguments passed to the
__call__ method.
returns the result of the cursor's execute method,
which is currently ignored by the __call__ method.
- encodeQuery(self, query, cursor=None)
- Encode query for use by the given cursor
Data and other attributes inherited from SQLQuery:
- debug = 0
- name = ''
Methods inherited from Propertied:
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01AEBCB0>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
|
class AttributeDefaultValue(SQLQuery) |
|
Queries for attribute default values
tableName -- name of the table |
|
- Method resolution order:
- AttributeDefaultValue
- SQLQuery
- Propertied
- object
Methods defined here:
- processResults(self, cursor, **named)
Data and other attributes defined here:
- sql = '\n\t\tSELECT\n\t\t\ta.adnum,\n\t\t\ta.adsrc\n\t\tFROM\n\t\t\tpg_at...elname=%%(tableName)s AND\n\t\t\tc.oid = a.adrelid;\n\t'
Methods inherited from SQLQuery:
- __call__(self, cursor, **namedarguments)
- Execute with cursor
cursor -- the pytable.dbcursor object to be
used for executing the query. Note that the
query will attempt to automatically coerce a
dbdriver or dbconnection object to a cursor
using that driver/connection. A log warning
will be returned if passing a driver (which
is not recommended, as it will result in
significant setup overhead (connections are
expensive to create for a single execution)).
namedarguments -- will be substituted using
python string substitution into the template
query string in order to create the final
query string. For single-execution queries
(SQLQuery), the namedarguments also represent
the row from which query arguments will be
taken. For multiple-execution queries
(SQLMultiQuery), the namedargument "dataSet"
is used as the executemany argument.
The "do" method takes care of the actual execution
of the query after cursor-coercion and query
substitution.
The "processResults" method takes the cursor and
returns the final result-set for the query which
will be the value returned from this function.
By default, this is simply a pointer to the cursor
used to execute the query.
- __init__(self, sql=None, debug=None, **named)
- Initialise the SQLQuery
sql -- sql string or None to use class' sql value
debug -- if provided (not None), override class' debug flag
- do(self, cursor, query, **namedarguments)
- Do the actual processing of the query (execute)
cursor -- a dbcursor object
query -- a final SQL query string, must be fully
substituted so that decree will operate properly
with the given cursor.
namedarguments -- for the single-query version,
(SQLQuery, this version), used as the dictionary
source for named and pyformat query arguments.
These are the same arguments passed to the
__call__ method.
returns the result of the cursor's execute method,
which is currently ignored by the __call__ method.
- encodeQuery(self, query, cursor=None)
- Encode query for use by the given cursor
Data and other attributes inherited from SQLQuery:
- debug = 0
- name = ''
Methods inherited from Propertied:
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01AEB950>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
|
class AttributeNumbers(SQLQuery) |
|
Query attnum:attname for a table
tableName -- name of the table
returns a dictionary of number:name |
|
- Method resolution order:
- AttributeNumbers
- SQLQuery
- Propertied
- object
Methods defined here:
- processResults(self, cursor, **named)
Data and other attributes defined here:
- sql = '\n\t\tSELECT\n\t\t\ta.attname, a.attnum\n\t\tFROM\n\t\t\tpg_at...lid AND\n\t\t\ta.attnum > 0\n\t\tORDER BY\n\t\t\ta.attnum;\n\t'
Methods inherited from SQLQuery:
- __call__(self, cursor, **namedarguments)
- Execute with cursor
cursor -- the pytable.dbcursor object to be
used for executing the query. Note that the
query will attempt to automatically coerce a
dbdriver or dbconnection object to a cursor
using that driver/connection. A log warning
will be returned if passing a driver (which
is not recommended, as it will result in
significant setup overhead (connections are
expensive to create for a single execution)).
namedarguments -- will be substituted using
python string substitution into the template
query string in order to create the final
query string. For single-execution queries
(SQLQuery), the namedarguments also represent
the row from which query arguments will be
taken. For multiple-execution queries
(SQLMultiQuery), the namedargument "dataSet"
is used as the executemany argument.
The "do" method takes care of the actual execution
of the query after cursor-coercion and query
substitution.
The "processResults" method takes the cursor and
returns the final result-set for the query which
will be the value returned from this function.
By default, this is simply a pointer to the cursor
used to execute the query.
- __init__(self, sql=None, debug=None, **named)
- Initialise the SQLQuery
sql -- sql string or None to use class' sql value
debug -- if provided (not None), override class' debug flag
- do(self, cursor, query, **namedarguments)
- Do the actual processing of the query (execute)
cursor -- a dbcursor object
query -- a final SQL query string, must be fully
substituted so that decree will operate properly
with the given cursor.
namedarguments -- for the single-query version,
(SQLQuery, this version), used as the dictionary
source for named and pyformat query arguments.
These are the same arguments passed to the
__call__ method.
returns the result of the cursor's execute method,
which is currently ignored by the __call__ method.
- encodeQuery(self, query, cursor=None)
- Encode query for use by the given cursor
Data and other attributes inherited from SQLQuery:
- debug = 0
- name = ''
Methods inherited from Propertied:
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01AEBC90>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
|
class ForeignConstraints(SQLQuery) |
| |
- Method resolution order:
- ForeignConstraints
- SQLQuery
- Propertied
- object
Methods defined here:
- processResults(self, cursor, **named)
Data and other attributes defined here:
- sql = "\n\tSELECT \n\t\tcon.conkey, -- local key-columns\n\t\t-...con.contype = 'f' AND\n\t\tc2.oid = con.confrelid\n\t;"
Methods inherited from SQLQuery:
- __call__(self, cursor, **namedarguments)
- Execute with cursor
cursor -- the pytable.dbcursor object to be
used for executing the query. Note that the
query will attempt to automatically coerce a
dbdriver or dbconnection object to a cursor
using that driver/connection. A log warning
will be returned if passing a driver (which
is not recommended, as it will result in
significant setup overhead (connections are
expensive to create for a single execution)).
namedarguments -- will be substituted using
python string substitution into the template
query string in order to create the final
query string. For single-execution queries
(SQLQuery), the namedarguments also represent
the row from which query arguments will be
taken. For multiple-execution queries
(SQLMultiQuery), the namedargument "dataSet"
is used as the executemany argument.
The "do" method takes care of the actual execution
of the query after cursor-coercion and query
substitution.
The "processResults" method takes the cursor and
returns the final result-set for the query which
will be the value returned from this function.
By default, this is simply a pointer to the cursor
used to execute the query.
- __init__(self, sql=None, debug=None, **named)
- Initialise the SQLQuery
sql -- sql string or None to use class' sql value
debug -- if provided (not None), override class' debug flag
- do(self, cursor, query, **namedarguments)
- Do the actual processing of the query (execute)
cursor -- a dbcursor object
query -- a final SQL query string, must be fully
substituted so that decree will operate properly
with the given cursor.
namedarguments -- for the single-query version,
(SQLQuery, this version), used as the dictionary
source for named and pyformat query arguments.
These are the same arguments passed to the
__call__ method.
returns the result of the cursor's execute method,
which is currently ignored by the __call__ method.
- encodeQuery(self, query, cursor=None)
- Encode query for use by the given cursor
Data and other attributes inherited from SQLQuery:
- debug = 0
- name = ''
Methods inherited from Propertied:
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01AEB930>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
|
class ListDatabases(SQLQuery) |
|
Queries PostgreSQL server for list of database-names
returns a simple list of string names |
|
- Method resolution order:
- ListDatabases
- SQLQuery
- Propertied
- object
Methods defined here:
- processResults(self, cursor, **namedarguments)
- Read database name list from cursor
Data and other attributes defined here:
- sql = "SELECT datname FROM pg_database WHERE datname != 'template1' AND datname != 'template0'"
Methods inherited from SQLQuery:
- __call__(self, cursor, **namedarguments)
- Execute with cursor
cursor -- the pytable.dbcursor object to be
used for executing the query. Note that the
query will attempt to automatically coerce a
dbdriver or dbconnection object to a cursor
using that driver/connection. A log warning
will be returned if passing a driver (which
is not recommended, as it will result in
significant setup overhead (connections are
expensive to create for a single execution)).
namedarguments -- will be substituted using
python string substitution into the template
query string in order to create the final
query string. For single-execution queries
(SQLQuery), the namedarguments also represent
the row from which query arguments will be
taken. For multiple-execution queries
(SQLMultiQuery), the namedargument "dataSet"
is used as the executemany argument.
The "do" method takes care of the actual execution
of the query after cursor-coercion and query
substitution.
The "processResults" method takes the cursor and
returns the final result-set for the query which
will be the value returned from this function.
By default, this is simply a pointer to the cursor
used to execute the query.
- __init__(self, sql=None, debug=None, **named)
- Initialise the SQLQuery
sql -- sql string or None to use class' sql value
debug -- if provided (not None), override class' debug flag
- do(self, cursor, query, **namedarguments)
- Do the actual processing of the query (execute)
cursor -- a dbcursor object
query -- a final SQL query string, must be fully
substituted so that decree will operate properly
with the given cursor.
namedarguments -- for the single-query version,
(SQLQuery, this version), used as the dictionary
source for named and pyformat query arguments.
These are the same arguments passed to the
__call__ method.
returns the result of the cursor's execute method,
which is currently ignored by the __call__ method.
- encodeQuery(self, query, cursor=None)
- Encode query for use by the given cursor
Data and other attributes inherited from SQLQuery:
- debug = 0
- name = ''
Methods inherited from Propertied:
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01AEB930>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
|
class ListDatatypes(SQLQuery) |
|
Queries PostgreSQL server for list of base data-type names
Only lists the set of defined, non-array base data-types
returns typname:oid mapping |
|
- Method resolution order:
- ListDatatypes
- SQLQuery
- Propertied
- object
Methods defined here:
- processResults(self, cursor, **namedarguments)
- Read database name list from cursor
Data and other attributes defined here:
- sql = 'SELECT\n\t\ttypname, oid\n\tFROM\n\t\tpg_type\n\tWHERE\n\t\tt...lable\n\tAND\n\t\ttypelem=0 -- is not an array type\n\t;'
Methods inherited from SQLQuery:
- __call__(self, cursor, **namedarguments)
- Execute with cursor
cursor -- the pytable.dbcursor object to be
used for executing the query. Note that the
query will attempt to automatically coerce a
dbdriver or dbconnection object to a cursor
using that driver/connection. A log warning
will be returned if passing a driver (which
is not recommended, as it will result in
significant setup overhead (connections are
expensive to create for a single execution)).
namedarguments -- will be substituted using
python string substitution into the template
query string in order to create the final
query string. For single-execution queries
(SQLQuery), the namedarguments also represent
the row from which query arguments will be
taken. For multiple-execution queries
(SQLMultiQuery), the namedargument "dataSet"
is used as the executemany argument.
The "do" method takes care of the actual execution
of the query after cursor-coercion and query
substitution.
The "processResults" method takes the cursor and
returns the final result-set for the query which
will be the value returned from this function.
By default, this is simply a pointer to the cursor
used to execute the query.
- __init__(self, sql=None, debug=None, **named)
- Initialise the SQLQuery
sql -- sql string or None to use class' sql value
debug -- if provided (not None), override class' debug flag
- do(self, cursor, query, **namedarguments)
- Do the actual processing of the query (execute)
cursor -- a dbcursor object
query -- a final SQL query string, must be fully
substituted so that decree will operate properly
with the given cursor.
namedarguments -- for the single-query version,
(SQLQuery, this version), used as the dictionary
source for named and pyformat query arguments.
These are the same arguments passed to the
__call__ method.
returns the result of the cursor's execute method,
which is currently ignored by the __call__ method.
- encodeQuery(self, query, cursor=None)
- Encode query for use by the given cursor
Data and other attributes inherited from SQLQuery:
- debug = 0
- name = ''
Methods inherited from Propertied:
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01AEB950>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
|
class ListIndices(SQLQuery) |
|
Get index-data-records for a given table
XXX Should build actual Index objects here, not
just return data-values for interpretation. |
|
- Method resolution order:
- ListIndices
- SQLQuery
- Propertied
- object
Methods defined here:
- processResults(self, cursor, **named)
- returns results of the selection as an unadorned set
Data and other attributes defined here:
- sql = '\n\t\tSELECT\n\t\t\ti.indexrelid, -- the key-ID of the ... key in table catalog\n\t\tORDER BY\n\t\t\tc2.relname;\n\t'
Methods inherited from SQLQuery:
- __call__(self, cursor, **namedarguments)
- Execute with cursor
cursor -- the pytable.dbcursor object to be
used for executing the query. Note that the
query will attempt to automatically coerce a
dbdriver or dbconnection object to a cursor
using that driver/connection. A log warning
will be returned if passing a driver (which
is not recommended, as it will result in
significant setup overhead (connections are
expensive to create for a single execution)).
namedarguments -- will be substituted using
python string substitution into the template
query string in order to create the final
query string. For single-execution queries
(SQLQuery), the namedarguments also represent
the row from which query arguments will be
taken. For multiple-execution queries
(SQLMultiQuery), the namedargument "dataSet"
is used as the executemany argument.
The "do" method takes care of the actual execution
of the query after cursor-coercion and query
substitution.
The "processResults" method takes the cursor and
returns the final result-set for the query which
will be the value returned from this function.
By default, this is simply a pointer to the cursor
used to execute the query.
- __init__(self, sql=None, debug=None, **named)
- Initialise the SQLQuery
sql -- sql string or None to use class' sql value
debug -- if provided (not None), override class' debug flag
- do(self, cursor, query, **namedarguments)
- Do the actual processing of the query (execute)
cursor -- a dbcursor object
query -- a final SQL query string, must be fully
substituted so that decree will operate properly
with the given cursor.
namedarguments -- for the single-query version,
(SQLQuery, this version), used as the dictionary
source for named and pyformat query arguments.
These are the same arguments passed to the
__call__ method.
returns the result of the cursor's execute method,
which is currently ignored by the __call__ method.
- encodeQuery(self, query, cursor=None)
- Encode query for use by the given cursor
Data and other attributes inherited from SQLQuery:
- debug = 0
- name = ''
Methods inherited from Propertied:
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01AEB730>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
|
class ListTables(SQLQuery) |
|
Queries connection/cursor for list of table-names
returns a simple list of string names |
|
- Method resolution order:
- ListTables
- SQLQuery
- Propertied
- object
Methods defined here:
- processResults(self, cursor, **namedarguments)
- Read table name list from cursor
Data and other attributes defined here:
- sql = "SELECT tablename FROM pg_tables WHERE tablename !~ '^pg_' AND tablename !~ '^pga_';"
Methods inherited from SQLQuery:
- __call__(self, cursor, **namedarguments)
- Execute with cursor
cursor -- the pytable.dbcursor object to be
used for executing the query. Note that the
query will attempt to automatically coerce a
dbdriver or dbconnection object to a cursor
using that driver/connection. A log warning
will be returned if passing a driver (which
is not recommended, as it will result in
significant setup overhead (connections are
expensive to create for a single execution)).
namedarguments -- will be substituted using
python string substitution into the template
query string in order to create the final
query string. For single-execution queries
(SQLQuery), the namedarguments also represent
the row from which query arguments will be
taken. For multiple-execution queries
(SQLMultiQuery), the namedargument "dataSet"
is used as the executemany argument.
The "do" method takes care of the actual execution
of the query after cursor-coercion and query
substitution.
The "processResults" method takes the cursor and
returns the final result-set for the query which
will be the value returned from this function.
By default, this is simply a pointer to the cursor
used to execute the query.
- __init__(self, sql=None, debug=None, **named)
- Initialise the SQLQuery
sql -- sql string or None to use class' sql value
debug -- if provided (not None), override class' debug flag
- do(self, cursor, query, **namedarguments)
- Do the actual processing of the query (execute)
cursor -- a dbcursor object
query -- a final SQL query string, must be fully
substituted so that decree will operate properly
with the given cursor.
namedarguments -- for the single-query version,
(SQLQuery, this version), used as the dictionary
source for named and pyformat query arguments.
These are the same arguments passed to the
__call__ method.
returns the result of the cursor's execute method,
which is currently ignored by the __call__ method.
- encodeQuery(self, query, cursor=None)
- Encode query for use by the given cursor
Data and other attributes inherited from SQLQuery:
- debug = 0
- name = ''
Methods inherited from Propertied:
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01AEBC90>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
|
class TableStructure(SQLQuery) |
|
Reverse-engineer table structure/schema from database
This is a very heavy mechanism for design-time use
which attempts to describe a table in the database
using the dbschema objects which would normally
be used to proactively define how we interact with
the table.
There are actually three different queries being
done during the TableStructure query. The first
is the base query, which simply retrieves the
DB API 2.0 column descriptions. These provide
much of the basic information required.
The second stage retrieves the foreign-key
constraints for the table. Eventually this should
also return general constraints (check restraints)
to allow for automatically setting up constraint
numeric and/or string data types.
The third stage retrieves information about indices
on the table. This includes primary, unique and
multi-field indices, but not check indices. |
|
- Method resolution order:
- TableStructure
- SQLQuery
- Propertied
- object
Methods defined here:
- processResults(self, cursor, tableName, **namedarguments)
- Build Table and Field descriptors through introspection
Data and other attributes defined here:
- sql = '\n\tSELECT *\n\tFROM %(tableName)s\n\tLIMIT 1; -- this will hopefully optimize the query somewhat\n\t'
Methods inherited from SQLQuery:
- __call__(self, cursor, **namedarguments)
- Execute with cursor
cursor -- the pytable.dbcursor object to be
used for executing the query. Note that the
query will attempt to automatically coerce a
dbdriver or dbconnection object to a cursor
using that driver/connection. A log warning
will be returned if passing a driver (which
is not recommended, as it will result in
significant setup overhead (connections are
expensive to create for a single execution)).
namedarguments -- will be substituted using
python string substitution into the template
query string in order to create the final
query string. For single-execution queries
(SQLQuery), the namedarguments also represent
the row from which query arguments will be
taken. For multiple-execution queries
(SQLMultiQuery), the namedargument "dataSet"
is used as the executemany argument.
The "do" method takes care of the actual execution
of the query after cursor-coercion and query
substitution.
The "processResults" method takes the cursor and
returns the final result-set for the query which
will be the value returned from this function.
By default, this is simply a pointer to the cursor
used to execute the query.
- __init__(self, sql=None, debug=None, **named)
- Initialise the SQLQuery
sql -- sql string or None to use class' sql value
debug -- if provided (not None), override class' debug flag
- do(self, cursor, query, **namedarguments)
- Do the actual processing of the query (execute)
cursor -- a dbcursor object
query -- a final SQL query string, must be fully
substituted so that decree will operate properly
with the given cursor.
namedarguments -- for the single-query version,
(SQLQuery, this version), used as the dictionary
source for named and pyformat query arguments.
These are the same arguments passed to the
__call__ method.
returns the result of the cursor's execute method,
which is currently ignored by the __call__ method.
- encodeQuery(self, query, cursor=None)
- Encode query for use by the given cursor
Data and other attributes inherited from SQLQuery:
- debug = 0
- name = ''
Methods inherited from Propertied:
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01AEBB50>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
| |