Package skytools :: Module sqltools
[frames] | no frames]

Module sqltools

source code

Database tools.

Classes
  Snapshot
Represents a PostgreSQL snapshot.
  CopyPipe
Splits one big COPY to chunks.
  DBObject
Base class for installable DB objects.
  DBSchema
Handles db schema.
  DBTable
Handles db table.
  DBFunction
Handles db function.
  DBLanguage
Handles db language.
Functions
 
fq_name_parts(tbl)
Return fully qualified name parts.
source code
 
fq_name(tbl)
Return fully qualified name.
source code
 
get_table_oid(curs, table_name) source code
 
get_table_pkeys(curs, tbl) source code
 
get_table_columns(curs, tbl) source code
 
exists_schema(curs, schema) source code
 
exists_table(curs, table_name) source code
 
exists_type(curs, type_name) source code
 
exists_function(curs, function_name, nargs) source code
 
exists_language(curs, lang_name) source code
 
magic_insert(curs, tablename, data, fields=None, use_insert=0)
Copy/insert a list of dict/list data to database.
source code
 
db_copy_from_dict(curs, tablename, dict_list, fields=None)
Do a COPY FROM STDIN using list of dicts as source.
source code
 
db_copy_from_list(curs, tablename, row_list, fields)
Do a COPY FROM STDIN using list of lists as source.
source code
 
full_copy(tablename, src_curs, dst_curs, column_list=[])
COPY table from one db to another.
source code
 
db_install(curs, list, log=None)
Installs list of objects into db.
source code
Function Details

magic_insert(curs, tablename, data, fields=None, use_insert=0)

source code 

Copy/insert a list of dict/list data to database.

If curs == None, then the copy or insert statements are returned as string. For list of dict the field list is optional, as its possible to guess them from dict keys.