Prev
Next
Index->
contents
reference
index
search
external
Up->
dismod_at
database
input
rate_table
rate_table.py
rate_table.py
@(@\newcommand{\B}[1]{ {\bf #1} }
\newcommand{\R}[1]{ {\rm #1} }
\newcommand{\W}[1]{ \; #1 \; }@)@
This is dismod_at-20221105 documentation: Here is a link to its
current documentation
.
rate_table: Example and Test
def rate_table () :
import dismod_at
import copy
#
file_name = 'example.db'
new = True
connection = dismod_at. create_connection ( file_name, new)
cursor = connection. cursor ()
#
# create the rate table
col_name = [
'rate_name' , 'parent_smooth_id' , 'child_smooth_id' , 'child_nslist_id'
]
col_type = [
'text' , 'integer' , 'integer' , 'integer'
]
row_list = [
[ 'pini' , 0 , 1 , None],
[ 'iota' , 2 , 3 , None],
[ 'rho' , 2 , 3 , None],
[ 'chi' , 2 , 3 , None],
[ 'omega' , 2 , 3 , 0 ]
]
tbl_name = 'rate'
dismod_at. create_table ( connection, tbl_name, col_name, col_type, row_list)
# ----------------------------------------------------------------------
# include primary key in test
check_name = [ tbl_name + '_id' ] + col_name
check_list = list ()
for i in range ( len ( row_list) ) :
check_list. append ( [ i] + row_list[ i] )
#
row_list = dismod_at. get_row_list ( connection, tbl_name, check_name)
assert row_list == check_list
# ----------------------------------------------------------------------
connection. close ()
print ( 'rate_table: OK' )
Input File: example/table/rate_table.py