mnesia

export data from mnesia to excel

这一生的挚爱 提交于 2019-12-13 08:09:02
问题 I have the table user -record(person, {id, firstname, lastname}). this table contains this values : 1 francoi mocci 2 test tes my goal is how can I export this data from mnesia to excel I know the inverse way meaning transfer data from excel to mnesia the solution in this case is to converse the excel in csv.file then use this kind of code to parse the csv file : %%% --- csv parser in Erlang. ------ %%% To help process large csv files without loading them into %%% memory. Similar to the xml

ejabberd supervisor module

家住魔仙堡 提交于 2019-12-12 17:23:00
问题 I need to keep a gen_mod process running as it loops every minute and does some cleanup. However once every few days it will crash and I'll have to manually start it back up again. I could use a basic example of implementing a supervisor into ejabberd_sup so it can keep going. I am struggling to understand the examples that use gen_server. Thanks for the help. 回答1: Here's an example module combining ejabberd's gen_mod and OTP's gen_server . Explanation is inlined in the code. -module(cleaner)

Random bad_object_header mnesia/dets error

♀尐吖头ヾ 提交于 2019-12-11 04:22:23
问题 I am having a very weird error with mnesia. I have about 10 tables that mnesia is recording, and usually it works fine. However, in a certain place in my code, whenever I try to read from a particular table (trying to read from other tables is fine) I get a DETS error. I reduced my code to {atomic, ok} = mnesia:transaction(fun() -> [Entry] = mnesia:read(table_name, Key), ok end) I have a try / catch block around the transaction, and the error I get is this: error:{badmatch, {aborted, {

Extracting multiple row corresponding to a value in mnesia

混江龙づ霸主 提交于 2019-12-11 03:07:51
问题 Situation is:- i have mnesia tuples like {"Groupid(Primary key)","groupname","grouptype","creatorid","adminid","Member_list"}. Member_list="memberone@xyz,membertwo@xyz,memberthree@xyz".Now i want to extract all those rows in which membertwo@xyz exists.How to apply guard while selecting from mnesisa for this??Any pointers Now after going through the approach given by sherif following error is appearing in function checktable1:getRecords/1 (checktable1.erl, line 201) 37> checktable1:getRecords(

Is there a built-in mechanism for us to launch Mnesia in Elixir?

南笙酒味 提交于 2019-12-08 02:07:58
问题 It seems like that we can launch Mnesia only by typing iex --erl "--mnesia dir '~/doc/'" --name mynode . Can we just launch it without passing arguments to erl ? 回答1: You can set it up dynamically in your code. All the --erl instruction above does is to configure the mnesia application before it is started. You could achieve this by: # First load mnesia iex(1)> :application.load(:mnesia) :ok # Now configure the desired directory iex(2)> :application.set_env(:mnesia, :dir, 'sample') :ok #

How to stop ejabberd from using mnesia [closed]

☆樱花仙子☆ 提交于 2019-12-07 23:44:52
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I'm trying to establish a procedure for restoring my database from a crashed server to a new server. My server is running Ejabberd as an XMPP server, and I configured it to use postgresql instead of mnesia - or so I thought. My procedure goes something like "dump the contents of the original DB, run the new

Mnesia equivalent of SQL NOT IN

隐身守侯 提交于 2019-12-07 17:32:02
问题 I have two records: -record(foo, {timestamp, name}). -record(bar, {timestamp, name}). And I would like to execute a Mnesia query that mimics the following SQL query SELECT f.* FROM foo f WHERE f.timestamp NOT IN ( SELECT b.timestamp FROM boo b) What would be an efficient Mnesia equivalent? 回答1: Good Question ! Now, i have thought of two ways. One where we use qlc and another where we use mnesia's own table iteration methods with accumulators . Here is the first option: %% Here i use 'qlc',

How to read all the records of mnesia database in erlang?

时间秒杀一切 提交于 2019-12-07 06:18:04
问题 I ma new in erlang and I need to do some operations for all records I get from mnesia database. Result = mnesia:dirty_read(mydatabase, {key1, key2}), case Result of [] -> ?DEBUG("No such record found", []); [#mydatabase{key3 = Key3}] -> %% some operations end How can I add a loop to my code that execute some operations for all records? I am not even sure if the code above does it or not? 回答1: You could use mnesia:foldl/3 for that. It iterates over all records in a table, passing along an

Access distributed mnesia database from different nodes

社会主义新天地 提交于 2019-12-07 05:34:47
问题 I have a mnesia database containning different tables. I want to be able to access the tables from different Linux terminals. I have a function called add_record , which takes a few parameters, say name and id . I want to be able to call add_record on node1 and add record on node2 but I want to be updating the same table from different locations. I read a few sources and the only thing i found out was that i should use net_adm:ping (node2). but somehow I cant access the data from the table.

How Elixir can read remote node mnesia table

断了今生、忘了曾经 提交于 2019-12-07 03:38:54
问题 I am trying use Elixir to write program to access mnesia. I run iex shell in amazon linux. I tried to connect another node using Node.connect(:'hello@abc.com') which return true, then I want to run mnesia command on this remote node, I issue :mneisa.info However, it only returns local node mnesia info. How can I access the connected remote node's mnesia database? I have tried rpc_call, it works. But is it having more direct method to get the data from remote node mnesia. 回答1: Did you try: