-
PrismTable
This is a helper to hide all the details for reading, updating, deleting and creating data in a Prism table. It is created from Repo using the gettable(tdf, filter, sort) method. The best use of PrismTable is to use it for iterating in table as it support for rec in table:
cleanup None Stop multiview and clean up everything. deleterecord bool Delete the record given in the multiviw with or witout related data based on paramter delrelated
- row | the row to delete
- delrelated=False | if we want to relate data in subforms defined in Relattions as welldeleterecords bool Delete all records between fromrow and torow or a list of row given. Will delete ralated values based on parameter
- fromrow=-1 | start to delete from this if not -1, then we only use list istead
- torow=-1 | then end row to delete
- rowlist=None | a list of numbers of rows to delete, default is None mean just do the fromrow to torow
- delrelated=False | delete related data in subforms defined by the Related table as well. Default is Falsefieldvaluetoprismvalue str Make sure that the value saved to PRIMS is a valid one based on the tdf and the incoming type geterrorfilter str Return the error returned when setting the filter if any getgeneratedfilter str Return the filter generated by the system if you used the tuple, dict or ? query string. Else it just return the same as you put in. getreturnedfilter str If you have usesed query list to set a filter (that is the filter comes in as a array of field=val) this will return the filter generated and used by Prism. The filter in Prism will then have the form field1="strvalifstr" AND field2=123 AND field3="anotherstring" readrecord dict
listRead a record from the table and return it as dict or list based on asdict parameter
Parameters
- row | the row to return, -1 is new and 0 - to rowcount is records from the table
- asdict=True | to return as dict or list, default is dict
- defaultvalues={} | field values to use if requesting to read a new record (-1)
- dorestart=True | if restart the multiview after end, not used in iterationrowcount int Return the number of records that will be returned by the query updaterecord bool
dictUpdate or save as a new record for a single record at a time.
- row | the row to update (-1 means new record)
- fields=None | the fields to update when saving the record as a key value pair in a dict this is merged into the existing record, this step skipped if None
- rowbasedon=-1 | used to find the record to save as new when row is -1
- returndata=False | tell if a reread of data should be returned instead of result this means that we will return the updated values of the record as a dict or an empty dict if no result instead of True or FalseHow to use it for simple operations added here
from debdata3 import getrepo, uninitprism9 try: repo = getrepo("C:\\pathToYourApp", "AppName") table = repo.gettable("TableName",'fieldtoquery="toreturn"', (('sortonfield', 'in order'),)) for rec in table: print(rec["afield"]) uninitprism9() except Exception as e: print(e)
Iterating over a table and list one of the fields