| 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 | |||
| Overview Of: mysql | Top | Context Index | Next 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.add | Top | Context Index | Previous Function | Next 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_day | Top | Context Index | Previous Function | Next Function |
|
syntax: db.add_day(<date=None>,<inc=1>) description: Return day by inc after CURDATE or <date> |
| Function: obj.add_days | Top | Context Index | Previous Function | Next Function |
|
syntax: db.add_days(<date=None>,<inc=1>) description: Return day by inc after CURDATE or <date> |
| Function: obj.add_month | Top | Context Index | Previous Function | Next Function |
|
syntax: db.add_month(<date=None>,<inc=1>) description: Return month by inc after CURDATE or <date> |
| Function: obj.add_year | Top | Context Index | Previous Function | Next Function |
|
syntax: db.add_year(<date=None>,<inc=1>) description: Return year by inc after CURDATE or <date> |
| Function: obj.cell | Top | Context Index | Previous Function | Next Function |
|
syntax: db.cell(<col>,<table>,<kv>,<test=0>) description: Return one field from table with any number of key/value pairs. |
| Function: obj.cells | Top | Context Index | Previous Function | Next Function |
|
syntax: db.cells(<table>,<cols>,<whereD>,<test=None>) description: Get col values from one row. |
| Function: obj.compose_where | Top | Context Index | Previous Function | Next Function |
|
syntax: db.compose_where(<D>) compose multiple WHERE clauses. All ops are = |
| Function: obj.count | Top | Context Index | Previous Function | Next Function |
|
syntax: db.count(<table>,<clause={}>) description: Get a row count from table. for keycol and keyval, use WHERE clause. |
| Function: obj.curdate | Top | Context Index | Previous Function | Next Function |
|
syntax: db.curdate() Return the current date |
| Function: obj.date | Top | Context Index | Previous Function | Next Function |
|
syntax: db.date(<month=0,<day=0>,<year=0>) Get date in MySQL format. |
| Function: obj.dbg_update | Top | Context Index | Previous Function | Next 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.dexc | Top | Context Index | Previous Function | Next 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.extract | Top | Context Index | Previous Function | Next Function |
|
syntax: db.extract Following a rexc command, extract a column as a list. Returns: tuple |
| Function: obj.get | Top | Context Index | Previous Function | Next 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_cell | Top | Context Index | Previous Function | Next 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_cells | Top | Context Index | Previous Function | Next 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_col | Top | Context Index | Previous Function | Next Function |
|
syntax: db.get_col(<col_name>,<table_name>,<D=None>) description: Retrieve a column from a table. No WHERE clause. |
| Function: obj.get_cols | Top | Context Index | Previous Function | Next Function |
|
syntax: db.get_cols(<col_names>,<tab_name>,<D=None>,<IDndxs=()>) description: Get a set of columns from table. |
| Function: obj.get_dict | Top | Context Index | Previous Function | Next Function |
|
syntax: db.get_dict(<keycol>,<valcol>,<tab_name>) description: Returns a dictionary with keycol/valcol pairs. All are strings |
| Function: obj.get_first | Top | Context Index | Previous Function | Next Function |
|
syntax: db.get_first(<cmd>,<D=None>) Get first record from selection set. |
| Function: obj.get_fld | Top | Context Index | Previous Function | Next Function |
|
syntax: db.get_fld(<col>,<table>,<kv>) description: Return one field from table with key and keyvalue |
| Function: obj.get_flds | Top | Context Index | Previous Function | Next 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_last | Top | Context Index | Previous Function | Next Function |
|
syntax: db.get_last(<table>,<cols>,<keys>,<test=0>) description: Get the latest row assuming that ID is auto-incremented |
| Function: obj.get_link | Top | Context Index | Previous Function | Next Function |
|
syntax: db.get_link(<layout>,<key>) Shorthand for make_link, first 3 args in list/tuple. |
| Function: obj.get_row | Top | Context Index | Previous Function | Next Function |
|
syntax: db.get_row(<table>,<cols>,<simple_keys>,<link_key>) description: Used self.get to retrieve one row |
| Function: obj.get_rows | Top | Context Index | Previous Function | Next 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_ID | Top | Context Index | Previous Function | Next Function |
|
syntax: db.ins_ID() Return ID of last inserted record Note: 0 will be returned if there is no autonumber field |
| Function: obj.link | Top | Context Index | Previous Function | Next Function |
|
syntax: db.link(<table>,<column>,<key>) Shorthand for make_link. Note: <ID> column is hard-coded. |
| Function: obj.link_lst_ID | Top | Context Index | Previous Function | Next Function |
|
syntax: db.link_lst_ID(<name>,<key>) Retrieves: value in <name>, table lst_<name>, where ID = key |
| Function: obj.link_up | Top | Context Index | Previous Function | Next Function |
|
syntax: db.link_up(<name>,<D=None>) Special case. Append lst to name description: columns are retrieved as name, ID |
| Function: obj.lookup | Top | Context Index | Previous Function | Next Function |
|
syntax: db.lookup(<table>,<keycol>,<valcol>,<test=none>) description: Create a dictionary from a two columns in a table |
| Function: obj.make_link | Top | Context Index | Previous Function | Next 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_col | Top | Context Index | Previous Function | Next 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.now | Top | Context Index | Previous Function | Next Function |
|
syntax: db.now() Return current timestamp |
| Function: obj.paginate | Top | Context Index | Previous Function | Next Function |
|
syntax: db.paginate(<table>,<limit>,<clause={}>) description: Create a pagination list from limits return list of limits and offsets |
| Function: obj.rec | Top | Context Index | Previous Function | Next Function |
|
syntax: db.rec() Return currently referenced record. |
| Function: obj.rexc | Top | Context Index | Previous Function | Next Function |
|
syntax: db.rexc(<t=None>,<test=0>) description: Execute a query, with result set as tuple. Returns: number of records found |
| Function: obj.row | Top | Context Index | Previous Function | Next Function |
|
syntax: db.row(<key=None>) Fetch a row. Use <key> for one value. |
| Function: obj.rows | Top | Context Index | Previous Function | Next Function |
|
syntax: db.rows(<r=None>,mode=None) Retrieve some rows. If not r, return all. |
| Function: obj.show_cols | Top | Context Index | Previous Function | Next Function |
|
syntax: db.show_cols(<table>) Return column names for table. |
| Function: obj.specs | Top | Context Index | Previous Function | Next Function |
|
syntax: db.specs(<table>) Get the names and column descriptions |
| Function: obj.today | Top | Context Index | Previous Function | Next Function |
|
syntax: db.today() Today's date in MySQL format and datetime type. |
| Function: obj.update | Top | Context Index | Previous Function | Next 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.use | Top | Context Index | Previous Function | Next Function |
|
syntax: db.use(<db-name>) Change databases. |
| Function: obj.val | Top | Context Index | Previous Function |
|
syntax: db.val(<table>,<cols>,<whereD>,<test=None>) description: Get one column value |