next up previous index
Next: csv_storage and tab_storage Up: Data Storage Previous: dict_storage   Index


mysql_storage

The constructor of this class expects an entry storage_location in its argument resources or the 4 parameters hostname, username, password, and database_name to connect to a MySQL databse.

The methods load_table() and determine_field_names() interpret the entry table_name in their argument load_resources as the name of the MySQL table with the data to be loaded. In addition to entries passed from Dataset, it accepts an optional entry replace_nulls_with which gives a replacement value for those attribute values that have NULL in the MySQL table. By default this value is set to 0. If an attribute is stored as a character string and replace_nulls_with is not a character string, the missing values are replaced by an empty string to avoid difficulties with mixing characters and numerical values in one array.

The method write_dataset() accepts in write_resource (in addition to entries passed by the Dataset method write_dataset()) a boolean entry drop_table_flag which determines if the table to be written to (value of out_table_name) should be deleted before writing. Default behavior is do not delete. Note that this might cause the program to fail if the table already exists but its structure does not match to the attributes to be written.


next up previous index
Next: csv_storage and tab_storage Up: Data Storage Previous: dict_storage   Index
info (at) urbansim.org