Prev Next

@(@\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 .
Create a Database Table

Syntax
connection
tbl_name
col_name
     unique
col_type
row_list
tbl_name_id
Side Effects
Example

Syntax
dismod_at.create_table(
 
connectiontbl_namecol_namecol_typerow_list
)


connection
is a connection for this database.

tbl_name
is a str that specifies the name of the table.

col_name
is a list of str where the elements are the column names in the table that is created. The column name for the primary key, tbl_name_id must not be included in the list.

unique
If the column name tbl_name_name is in the list, the corresponding column will have the unique constraint.

col_type
is a list of str where the elements are the column types in the same order as col_name . The valid types are integer, real, text.

row_list
is a possibly empty list of rows contain data that is written to the table. Each row is itself a list containing the data for one row of the table in the same order as col_name . Note that the primary key column is not included in row_list . Also note that the value in each column gets converted to unicode before being written to the database. Note that the special value
 
row_list[i][j] ==  None
gets converted to null in the table.

tbl_name_id
A column with name tbl_name_id and type integer primary key is included as the first column in the table. Its values start with zero (for the first row) and increment by one for each row.

Side Effects
This routine does a
 
connection.commit()
to make sure the table exists before returning.

Example
The file create_table.py is an example use of create_table.
Input File: python/dismod_at/create_table.py