Mnesia DB adapter

122 views
Skip to first unread message

fanq

unread,
Jan 27, 2012, 9:46:50 AM1/27/12
to ChicagoBoss
I would like to use the mnesia db adapter, but I get the following
error on start-dev,
exception exit:
{aborted,{no_exists,usr,attributes}}

usr is tha name of a model. Should I make the tables myself ?

Best regards,
Stefan

Kai Janson

unread,
Jan 27, 2012, 1:11:59 PM1/27/12
to chica...@googlegroups.com
Hi Stefan,

Here is the entire documentation on Mnesia.


It's a good database, but keep in mind it was invented for small data all over the place.

—Kai

fanq

unread,
Jan 27, 2012, 4:53:28 PM1/27/12
to ChicagoBoss
Thanks for the link, I know about Mnesia. I was expecting the db
adapter to initialize the tables by itself at startup, based on my
models. Wouldn't that be a good idea ?

Graeme Defty

unread,
Jan 28, 2012, 7:02:57 PM1/28/12
to chica...@googlegroups.com
It probably would and there may be code in the other adaptors which could be used as a start point.

When I wrote the adaptor, I created a separate module caled dbutil which contains functions i needed for creating the tables and performing an initial load. I also put a simple update mechanism in there to upgrade the database in a repeatable way for new releases of my app. I execute all these manually from the command line.

Having that I did not need anything more, so di no further work on the adaptor. Looking at it now there are a couple of things I ould change, but time is pressing and I now have users to keep happy.

g
____________________________________________________

Geeth

unread,
Feb 13, 2012, 12:03:24 PM2/13/12
to chica...@googlegroups.com
I am trying to get my newbie test project to work against some persistent DB switching it from Mock. I didn't have much luck with Riak, so I switched to Mnesia.
I went through Graeme's dbutil code and was able to initialize mnesia from within CB shell. I still get an error when try to start DB with mnesia as DB. 

Here is Boss.config and Model.

I am seeing this in CB shell:

=SUPERVISOR REPORT==== 13-Feb-2012::10:42:49 ===
     Supervisor: {local,boss_sup}
     Context:    start_error
     Reason:     {function_clause,
                     [{boss_db_adapter_mnesia,init,
                          [[{adapter,mnesia},
                            {cache_enable,false},
                            {shards,[]},
                            {is_master_node,true},
                            {db_host,"localhost"},
                            {db_port,1978}]]},
                      {boss_db,start,1},
                      {boss_web_controller,init,1},
                      {gen_server,init_it,6},
                      {proc_lib,init_p_do_apply,3}]}
     Offender:   [{pid,undefined},
                  {name,boss_web_controller},
                  {mfargs,
                      {boss_web_controller,start_link,
                          [[{ip,"0.0.0.0"},{port,8001}]]}},
                  {restart_type,permanent},
                  {shutdown,5000},
                  {child_type,worker}]

Thanks.
Geeth

Evan Miller

unread,
Feb 14, 2012, 10:16:24 AM2/14/12
to chica...@googlegroups.com
Try this

https://github.com/evanmiller/boss_db/commit/61c4d70161d2bb3cbcfb9c078aeb44fd6ebe122a

Still ironing out the bugs from the BossDB process remodeling.

--
Evan Miller
http://www.evanmiller.org/

douglasv

unread,
Feb 14, 2012, 10:51:20 AM2/14/12
to ChicagoBoss
it may be that before you can start mesia, you first have to 1>
mnesia:create_schema(etc).

On Feb 14, 10:16 am, Evan Miller <emmil...@gmail.com> wrote:
> Try this
>
> https://github.com/evanmiller/boss_db/commit/61c4d70161d2bb3cbcfb9c07...

Geeth

unread,
Feb 14, 2012, 3:09:42 PM2/14/12
to chica...@googlegroups.com
Thanks Evan. That did it. Works like a charm.

-Geeth

tmrf...@gmail.com

unread,
Mar 15, 2012, 9:18:28 AM3/15/12
to chica...@googlegroups.com
BTW, for this purpose, I am using this code (stored in priv/init/whatever.erl):

Evan Miller

unread,
Mar 17, 2012, 1:54:01 PM3/17/12
to chica...@googlegroups.com
On Thu, Mar 15, 2012 at 8:18 AM, <tmrf...@gmail.com> wrote:
> BTW, for this purpose, I am using this code (stored in
> priv/init/whatever.erl):
>   http://pastebin.com/tejNngRK

This looks very cool! It might be nice to have a "make schema" target
that executes this code. With type-hinting, we could also support
"make schema" with SQL databases.

In any event you might want to add this info to the wiki on GitHub so
it doesn't get lost.

Evan

>
> On Tuesday, February 14, 2012 4:51:20 PM UTC+1, douglasv wrote:
>>
>> it may be that before you can start mesia,  you first have to 1>
>> mnesia:create_schema(etc).

--
Evan Miller
http://www.evanmiller.org/

ll...@writersglen.com

unread,
Mar 17, 2012, 2:22:32 PM3/17/12
to chica...@googlegroups.com
Hi,

I've been developing an app using mnesia, so I greatly look forward to seeing how to use this in the wiki.

Thanks,

LRP

tmrf...@gmail.com

unread,
Mar 19, 2012, 1:41:11 PM3/19/12
to chica...@googlegroups.com
https://github.com/evanmiller/ChicagoBoss/wiki/Automatic-schema-initialization-for-mnesia


Dne sobota, 17. března 2012 19:22:32 UTC+1 LRP napsal(a):
Hi,

I've been developing an app using mnesia, so I greatly look forward to seeing how to use this in the wiki.

Thanks,

LRP

-----Original Message-----
From: "Evan Miller"
Sent: Saturday, March 17, 2012 1:54pm
Subject: Re: Mnesia DB adapter

Reply all
Reply to author
Forward
0 new messages