function DB = database_definition(IDcompany,FileName)

text = 'database_definition function started';
fileID = fopen(FileName,'a');
fmt = '%s \r';
fprintf(fileID,fmt,text);

%% DB ASE
Dati = importdata('DB.txt');
dbname = Dati{1,1};
username = Dati{2,1};
password = Dati{3,1};
driver = Dati{4,1};
dburl = Dati{5,1};

DB{1,1} = cellstr(dbname);
DB{2,1} = cellstr(username);
DB{3,1} = cellstr(password);
DB{4,1} = cellstr(driver);
DB{5,1} = cellstr(dburl);

% conn = database(dbname, username, password, driver, dburl);
    
% comando = ['select db_name, db_user, db_pwd from companies where id = '''...
%     IDcompany ''' '];
% curs = exec(conn,comando);
% curs = fetch(curs);
% Credenziali = curs.Data;    
% dbname = Credenziali(1,1);
% username = Credenziali(1,2);
% password = Credenziali(1,3);

% close(conn)

% dbname = char(dbname);
% username = char(username);
% password = char(password);
% driver = char(driver);
% dburl = dburl(1,1:end-7);
% dburl = char(strcat(dburl,char(dbname)));
% dburl = char(dburl);

% DB(1,1) = dbname;
% DB(2,1) = username;
% DB(3,1) = password;
% DB(4,1) = cellstr(driver);
% dburl = dburl(1,1:end-7);
% dburl = char(strcat(dburl,char(dbname)));
% DB{5,1} = cellstr(dburl);

% File = 'DB_New.txt';
% outdat = fopen(File,'wt+');
% fileID = fopen(File,'a');
% fmt = '%s \r';
% fprintf(fileID,fmt,dbname);
% fprintf(fileID,fmt,username);
% fprintf(fileID,fmt,password);
% fprintf(fileID,fmt,driver);
% fprintf(fileID,fmt,dburl);
% fclose(fileID);


text = 'Database defined correctly. database_definition function ended';
fprintf(fileID,fmt,text);
fclose(fileID);
end
