Documentation for Module: mysql.py ||  Module Index

General: !Overview Wrapper for MySQLdb.
author: Tim Johnson tim@akwebsoft.com

Context Index
mysql Functions: ==>
OVERVIEW curdate get_dict link rexc
add date get_first link_lst_ID row
add_day dbg_update get_fld link_up rows
add_days dexc get_flds lookup show_cols
add_month extract get_last make_link specs
add_year get get_link match_col today
cell get_cell get_row now update
cells get_cells get_rows paginate use
compose_where get_col ins_ID rec val
count get_cols      

Context: mysql

Overview Of: mysqlTopContext IndexNext Function
    General: Initialize: object = mysql(<Profile-list-or-dict>)
    Arg: list - ['hostname','user','pwd','database']
    OR: with Dictionary {'hostname':'host','user':'user','pwd':'secret','database':'database'}
Function: obj.addTopContext IndexPrevious FunctionNext Function
    syntax: db.add(<tablename>,<recordD>,<test=None>,<createCol="">)
    description: Add new record as dictionary (column/value pairs)
    Arg: test - Print out command. createCol - column to initialize with current timestamp.
Function: obj.add_dayTopContext IndexPrevious FunctionNext Function
    syntax: db.add_day(<date=None>,<inc=1>)
    description: Return day by inc after CURDATE or <date>
Function: obj.add_daysTopContext IndexPrevious FunctionNext Function
    syntax: db.add_days(<date=None>,<inc=1>)
    description: Return day by inc after CURDATE or <date>
Function: obj.add_monthTopContext IndexPrevious FunctionNext Function
    syntax: db.add_month(<date=None>,<inc=1>)
    description: Return month by inc after CURDATE or <date>
Function: obj.add_yearTopContext IndexPrevious FunctionNext Function
    syntax: db.add_year(<date=None>,<inc=1>)
    description: Return year by inc after CURDATE or <date>
Function: obj.cellTopContext IndexPrevious FunctionNext Function
    syntax: db.cell(<col>,<table>,<kv>,<test=0>)
    description: Return one field from table with any number of key/value pairs.
Function: obj.cellsTopContext IndexPrevious FunctionNext Function
    syntax: db.cells(<table>,<cols>,<whereD>,<test=None>)
    description: Get col values from one row.
Function: obj.compose_whereTopContext IndexPrevious FunctionNext Function
    syntax: db.compose_where(<D>) compose multiple WHERE clauses. All ops are =
Function: obj.countTopContext IndexPrevious FunctionNext Function
    syntax: db.count(<table>,<clause={}>)
    description: Get a row count from table. for keycol and keyval, use WHERE clause.
Function: obj.curdateTopContext IndexPrevious FunctionNext Function
    syntax: db.curdate() Return the current date
Function: obj.dateTopContext IndexPrevious FunctionNext Function
    syntax: db.date(<month=0,<day=0>,<year=0>) Get date in MySQL format.
Function: obj.dbg_updateTopContext IndexPrevious FunctionNext Function
    syntax: db.dbg_update(<table>,<tableD>,<keycol>,<keyval>,<test=0>)
    description: Step thru an update, adding a column a time and then trap
      the last column name
Function: obj.dexcTopContext IndexPrevious FunctionNext Function
    syntax: db.dexc(<str-command>,<t=None>,<test=0>)
    description: Execute a query, with result set as dictionary.
    Returns: number of records found
Function: obj.extractTopContext IndexPrevious FunctionNext Function
    syntax: db.extract Following a rexc command, extract a column as a list.
    Returns: tuple
Function: obj.getTopContext IndexPrevious FunctionNext Function
    syntax: db.get(<*cmds>) Execute a complex command in parts.
    description: To display the parts, first call self.test().
     For error-free testing, make sure that a tuple has
     elements equal to the number of %s place markers in the previous string.
    Example: db.set_test()
      res=db.get("SELECT %s.*,kbAccount.email,kbAccount.phone,kbAccount.contact_name,kbAccount.fax" % table,
          "FROM %s,kbAccount WHERE " % table,
          "kbAccount.ID=%s.Member_ID AND %s.mls_no=('%s')"
          % (table,table,mls_no),
          "LIMIT 1")
Function: obj.get_cellTopContext IndexPrevious FunctionNext Function
    syntax: db.get_cell(<target>,<table>,<keycol>,<keyval>,<D=None>)
    description: Get one cell from a table based on a key value
Function: obj.get_cellsTopContext IndexPrevious FunctionNext Function
    syntax: db.get_cells(<target>,<table>,<keycol>,<keyval>,<D=None>)
    description: Get any number of cells from a table based on a key value
Function: obj.get_colTopContext IndexPrevious FunctionNext Function
    syntax: db.get_col(<col_name>,<table_name>,<D=None>)
    description: Retrieve a column from a table. No WHERE clause.
Function: obj.get_colsTopContext IndexPrevious FunctionNext Function
    syntax: db.get_cols(<col_names>,<tab_name>,<D=None>,<IDndxs=()>)
    description: Get a set of columns from table.
Function: obj.get_dictTopContext IndexPrevious FunctionNext Function
    syntax: db.get_dict(<keycol>,<valcol>,<tab_name>)
    description: Returns a dictionary with keycol/valcol pairs. All are strings
Function: obj.get_firstTopContext IndexPrevious FunctionNext Function
    syntax: db.get_first(<cmd>,<D=None>) Get first record from selection set.
Function: obj.get_fldTopContext IndexPrevious FunctionNext Function
    syntax: db.get_fld(<col>,<table>,<kv>)
    description: Return one field from table with key and keyvalue
Function: obj.get_fldsTopContext IndexPrevious FunctionNext Function
    syntax: db.get_flds(<col_names>,<table_name>,<kv>,<D=None>)
    description: Return series of columns from table as one row
Function: obj.get_lastTopContext IndexPrevious FunctionNext Function
    syntax: db.get_last(<table>,<cols>,<keys>,<test=0>)
    description: Get the latest row assuming that ID is auto-incremented
Function: obj.get_linkTopContext IndexPrevious FunctionNext Function
    syntax: db.get_link(<layout>,<key>) Shorthand for make_link, first 3 args in list/tuple.
Function: obj.get_rowTopContext IndexPrevious FunctionNext Function
    syntax: db.get_row(<table>,<cols>,<simple_keys>,<link_key>)
    description: Used self.get to retrieve one row
Function: obj.get_rowsTopContext IndexPrevious FunctionNext Function
    syntax: db.get_rows(<nrows>,<table>,<cols>,<simple_keys>,<link_keys=None>)
    description: Retrieve n rows with cols from table where dictionary simple_keys
      point to a keycolumn:value in table (string). and link_keys are normalized links.
    cols: may be 1): *, in which case a block of all columns from table is composed
                 2): comma-delimited string which is decomposed into list.
                 3): list of column names
    link_keys: will evaluate to None or be a list with elements of following
    composition:: Each element with be a block of four sub-elements or a string with
       four white-space delimited words which will be decomposed into four sub-elements.
    SubElements:: [0] common column key name in table, [1] source table
                  [2] common column key name in source table [3] value column
    Example:
       res=db.get_row('kbListing',"*",{"Trans_ID":Trans_ID},
                      ["city_area GeoCities Composite_ID city",
                       "borough GeoCounties Composite_ID county"]
Function: obj.ins_IDTopContext IndexPrevious FunctionNext Function
    syntax: db.ins_ID() Return ID of last inserted record
    Note: 0 will be returned if there is no autonumber field
Function: obj.linkTopContext IndexPrevious FunctionNext Function
    syntax: db.link(<table>,<column>,<key>) Shorthand for make_link.
    Note: <ID> column is hard-coded.
Function: obj.link_lst_IDTopContext IndexPrevious FunctionNext Function
    syntax: db.link_lst_ID(<name>,<key>)
    Retrieves: value in <name>, table lst_<name>, where ID = key
Function: obj.link_upTopContext IndexPrevious FunctionNext Function
    syntax: db.link_up(<name>,<D=None>) Special case. Append lst to name
    description: columns are retrieved as name, ID
Function: obj.lookupTopContext IndexPrevious FunctionNext Function
    syntax: db.lookup(<table>,<keycol>,<valcol>,<test=none>)
    description: Create a dictionary from a two columns in a table
Function: obj.make_linkTopContext IndexPrevious FunctionNext Function
    syntax: db.make_link(<val_col>,<val_table>,<key_col>,<key>)
    description: Find the corresponding value in target for a numeric key in src.
Function: obj.match_colTopContext IndexPrevious FunctionNext Function
    syntax: db.match_col(<col_name>,<tab_name>,<keycol>,<keyval>)
    description: Retrieve a column from a table with a simple WHERE clause.
Function: obj.nowTopContext IndexPrevious FunctionNext Function
    syntax: db.now() Return current timestamp
Function: obj.paginateTopContext IndexPrevious FunctionNext Function
    syntax: db.paginate(<table>,<limit>,<clause={}>)
    description: Create a pagination list from limits return list of limits and offsets
Function: obj.recTopContext IndexPrevious FunctionNext Function
    syntax: db.rec() Return currently referenced record.
Function: obj.rexcTopContext IndexPrevious FunctionNext Function
    syntax: db.rexc(<t=None>,<test=0>)
    description: Execute a query, with result set as tuple.
    Returns: number of records found
Function: obj.rowTopContext IndexPrevious FunctionNext Function
    syntax: db.row(<key=None>) Fetch a row. Use <key> for one value.
Function: obj.rowsTopContext IndexPrevious FunctionNext Function
    syntax: db.rows(<r=None>,mode=None) Retrieve some rows. If not r, return all.
Function: obj.show_colsTopContext IndexPrevious FunctionNext Function
    syntax: db.show_cols(<table>) Return column names for table.
Function: obj.specsTopContext IndexPrevious FunctionNext Function
    syntax: db.specs(<table>) Get the names and column descriptions
Function: obj.todayTopContext IndexPrevious FunctionNext Function
    syntax: db.today() Today's date in MySQL format and datetime type.
Function: obj.updateTopContext IndexPrevious FunctionNext Function
    syntax: db.update(<table>,<tableD>,<keycol>,<keyval>,<test=0>)
    description: Update a record, If keycol is a dictionary, built multiple where
      clause and keyval will be used instead of the test parameter.
Function: obj.useTopContext IndexPrevious FunctionNext Function
    syntax: db.use(<db-name>) Change databases.
Function: obj.valTopContext IndexPrevious Function
    syntax: db.val(<table>,<cols>,<whereD>,<test=None>)
    description: Get one column value