1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

paiza.ioでelixir その278

Posted at

概要

paiza.ioでelixirやってみた。
mnesiaやってみた。

サンプルコード



:mnesia.start()
:mnesia.create_table(:a, [attributes: [:key, :value]])
:mnesia.transaction(fn() -> 
    :mnesia.write({:a, :a, 1}) 
end)
:mnesia.transaction(fn() -> 
    :mnesia.write({:a, :b, 2}) 
end)
:mnesia.transaction(fn() -> 
    :mnesia.write({:a, :c, 3}) 
end)
:ets.i(:a)
:mnesia.dump_to_textfile('test_data')
|>IO.inspect

:mnesia.stop

:mnesia.create_schema([node()])
:mnesia.start
:mnesia.load_textfile('test_data')
:ets.i(:a)
:mnesia.system_info


実行結果

<1   > {a,a,1}
<2   > {a,b,2}
<3   > {a,c,3}
EOT  (q)uit (p)Digits (k)ill /Regexp -->:ok

22:40:31.762 [info]  Application mnesia exited: :stopped
New table a
<1   > {a,a,1}
<2   > {a,b,2}
<3   > {a,c,3}
EOT  (q)uit (p)Digits (k)ill /Regexp -->===> System info in version "4.16.2", debug level = none <===
opt_disc. Directory "/workspace/Mnesia.nonode@nohost" is used.
use fallback at restart = false
running db nodes   = [nonode@nohost]
stopped db nodes   = [] 
master node tables = []
remote             = []
ram_copies         = [a]
disc_copies        = [schema]
disc_only_copies   = []
[{nonode@nohost,disc_copies}] = [schema]
[{nonode@nohost,ram_copies}] = [a]
4 transactions committed, 0 aborted, 0 restarted, 2 logged to disc
0 held locks, 0 in queue; 0 local transactions, 0 remote
0 transactions waits for other nodes: []



成果物

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?