I want to access Mnesia database of ejabberd server, But i don't know how to read,write and update the data, Is there a way by which i can do this. Can i change Database to MySQL rather than Mnesia. I have tried this
{odbc_server, {mysql, "localhost", "xmpp_db", "root", "**********"}}.
Here "xmpp_db" is the name of my database which is created for ejabberd, But i does not see any change in xmpp_db. Should i create any tables in "xmpp_db", But problem is what are the names of my tables and fields. I also have used
ejabberdctl dump /tmp/ejabberd.db.txt
command, But this is just for read the data(the data is in very roughly format and hard to understand). Is there any way by which i can perform read, write and update operations on Mnesia database.
your help will be appreciated.
Is there any way by which i can perform read, write and update operations on Mnesia database?
General Info:
Using ejabberdctl
you can get a list of Mnesia general information, tables, records count, directory of its file and etc.
$ ejabberdctl mnesia [info]
Data Manipulation:
One way for reading Mnesia records is by attach to ejabberd console and call mnesia:dirty_read/2
function with desired arguments.
$ ejabberdctl debug
1> mnesia:dirty_read(passwd, {<<"username">>, <<"host">>}).
[{passwd,{<<"username">>,<<"host">>}, <<"password">>}]
Also for updating (or writing) Mnesia records you can call mnesia:dirty_write/2
function the same way.
$ ejabberdctl debug
1> mnesia:dirty_write({passwd, {<<"user">>, <<"host">>, <<"new-pass">>}).
ok
For learning other Mnesia's API check its official manual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With