"""Updates the mapping given by key with new key and value"""
k_id=get_kb_id(kb_name)
run_sql("""UPDATE fmtKNOWLEDGEBASEMAPPINGS
SET m_key = %s , m_value = %s
WHERE m_key = %s AND id_fmtKNOWLEDGEBASES = %s""",
(new_key,new_value,key,k_id))
returnTrue
defcreate_knowledge_bases_table():
"""
Create the table that holds knowledge bases
"""
# TO BE MOVED TO tabcreate.sql
query="""
CREATE TABLE IF NOT EXISTS fmtKNOWLEDGEBASES (
id mediumint(8) unsigned NOT NULL auto_increment,
name varchar(255) default '',
description text default '',
PRIMARY KEY (id),
UNIQUE KEY name (name)
) TYPE=MyISAM;"""
run_sql(query)
returnTrue
defcreate_kb_mappings_table():
"""
Create the table that holds all mappings of knowledge bases
"""
# TO BE MOVED TO tabcreate.sql
query="""
CREATE TABLE IF NOT EXISTS fmtKNOWLEDGEBASEMAPPINGS (
id mediumint(8) unsigned NOT NULL auto_increment,
m_key varchar(255) NOT NULL default '',
m_value text NOT NULL default '',
id_fmtKNOWLEDGEBASES mediumint(8) NOT NULL default '0',
PRIMARY KEY (id),
KEY id_fmtKNOWLEDGEBASES (id_fmtKNOWLEDGEBASES)
) TYPE=MyISAM;"""
run_sql(query)
# add_kb(marc_codes_mappings_kb_name, "Mapping from text label to marc codes. Used by bibformat in templates when calling <BFE_some_label /> for some_label that does not exist as element.")