This is a follow up question to : Adapting csv reading for multiple tables
If I have the following module defined:
:- module(csv_load_mod,[prepare_db/3]).
:- use_module(library(csv)).
:- set_prolog_stack(global, limit(4*10**9)).
prepare_db(File, Column_Key,Relation) :-
   Column_Key_Term =.. [Column_Key,_],
   Relation_Term =.. [Relation,_,_,_],
   retractall(Column_Key_Term),
   retractall(Relation_Term),
   forall(read_row(File, Row), store_row(Row,Column_Key,Relation)).
store_row(Row,Column_Key,Relation) :-
   Column_Key_Test =.. [Column_Key,ColKeys],
   Row =.. [row|Cols],
   (   call(Column_Key_Test)
   ->  Cols = [RowKey|Values],
       maplist(store_relation(Relation,RowKey), ColKeys, Values)
       ;   ( Cols = [_H|T],
             Column_Key_Term =.. [Column_Key,T],
             assertz(Column_Key_Term)
           )
   ).
store_relation(Relation,RowKey, ColKey, Values) :-
    Relation_Term =.. [Relation,RowKey,ColKey,Values],
    assertz(Relation_Term).
read_row(File, Row) :-
    csv_read_file_row(File, Row, []).
Then I am able to read a table from a csv file.
For example:
:? prepare_db('my_table.csv',mt_col_key, mt_relation).
I would then have a fact mt_col_key([col1,col2,...,coln]) and a set of facts mt_relation/3. But these will be local to the module and would not be exported. I need to use csv_load_mod:mt_relation/3 etc. Is there a way to get a module to export a dynamic predicate or adapt prepare_db/3 so the facts it asserts are not local or they get asserted to the module that called it?