Erlang/OTP Forums

Author Message

<  Erlyweb mailing list  ~  erlydb table abstraction file issue

Guest
Posted: Mon Jun 09, 2008 7:21 pm Reply with quote
Guest
Mysql database is running and has a schema simple with table simple.
Started erlydb like here:

erlydb:start(mysql, [{hostname, "localhost"}, {username, "simple"},
{password, "12345"}, {database, "simple"}, {pool_size, 10}]).

Not sure why I don't get the mysql table abstraction file(simple.erl)
when I execute the following. Also there aren't any error
messages/logs to look into:

3> erlydb:code_gen(["simple.erl"], mysql).
mysql_conn:426: fetch <<"show tables">> (id <0.81.0>)
mysql_conn:426: fetch <<"describe simple">> (id <0.81.0>)
debug:erlydb:355:

--- To skip foreign key checks, compile with the {skip_fk_checks, true} option

--
rk

That which we persist in doing becomes easier for us to do; not that
the nature of the thing itself is changed, but that our power to do is
increased.
-Ralph Waldo Emerson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist
Guest
Posted: Sun Jun 15, 2008 4:40 am Reply with quote
Guest
Try to pass the absolute path to "simple.erl" to code_gen(). Does that work?

On Mon, Jun 9, 2008 at 12:20 PM, db <masterofquestions@gmail.com> wrote:
>
> Mysql database is running and has a schema simple with table simple.
> Started erlydb like here:
>
> erlydb:start(mysql, [{hostname, "localhost"}, {username, "simple"},
> {password, "12345"}, {database, "simple"}, {pool_size, 10}]).
>
> Not sure why I don't get the mysql table abstraction file(simple.erl)
> when I execute the following. Also there aren't any error
> messages/logs to look into:
>
> 3> erlydb:code_gen(["simple.erl"], mysql).
> mysql_conn:426: fetch <<"show tables">> (id <0.81.0>)
> mysql_conn:426: fetch <<"describe simple">> (id <0.81.0>)
> debug:erlydb:355:
>
> --- To skip foreign key checks, compile with the {skip_fk_checks, true} option
>
> --
> rk
>
> That which we persist in doing becomes easier for us to do; not that
> the nature of the thing itself is changed, but that our power to do is
> increased.
> -Ralph Waldo Emerson
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist
Guest
Posted: Wed Jun 18, 2008 12:13 am Reply with quote
Guest
Absolute path to the file doesn't work either. Here is my table def:

CREATE TABLE `simple` (

`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(200) NOT NULL,

PRIMARY KEY (`id`)

) ENGINE=Innodb DEFAULT CHARSET=latin1;

11> erlydb:code_gen(["/home/db/project1/src/simple_test.erl"],{mysql,
[{allow_unsafe_statements, true}]}, [debug_info]).
mysql_conn:426: fetch <<"show tables">> (id <0.81.0>)
mysql_conn:426: fetch <<"describe simple">> (id <0.81.0>)
debug:erlydb:355:

--- To skip foreign key checks, compile with the {skip_fk_checks,
true} option


ok

On Jun 15, 12:39 am, "Yariv Sadan" <yarivsa...@gmail.com> wrote:
> Try to pass the absolute path to "simple.erl" to code_gen(). Does that work?
>
> On Mon, Jun 9, 2008 at 12:20 PM, db <masterofquesti...@gmail.com> wrote:
>
> > Mysql database is running and has a schema simple with table simple.
> > Started erlydb like here:
>
> > erlydb:start(mysql, [{hostname, "localhost"}, {username, "simple"},
> > {password, "12345"}, {database, "simple"}, {pool_size, 10}]).
>
> > Not sure why I don't get the mysql table abstraction file(simple.erl)
> > when I execute the following. Also there aren't any error
> > messages/logs to look into:
>
> > 3> erlydb:code_gen(["simple.erl"], mysql).
> > mysql_conn:426: fetch <<"show tables">> (id <0.81.0>)
> > mysql_conn:426: fetch <<"describe simple">> (id <0.81.0>)
> > debug:erlydb:355:
>
> > --- To skip foreign key checks, compile with the {skip_fk_checks, true} option
>
> > --
> > rk
>
> > That which we persist in doing becomes easier for us to do; not that
> > the nature of the thing itself is changed, but that our power to do is
> > increased.
> > -Ralph Waldo Emerson
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist
Guest
Posted: Tue Jun 24, 2008 5:07 am Reply with quote
Guest
The erlydb.erl is complaining that the filename we pass as a invalid
module
debug:erlydb:405: Error: {error,{invalid_module,
[116,101,115,116,46,101,114,108]}}
debug:erlydb:364: calling gen_module_code
[116,101,115,116,46,101,114,108]


btw..
in erlydb.erl at line 404
Err -
>
Err
i guess we need a debug statement ?


On Jun 17, 5:01
Guest
Posted: Wed Jun 25, 2008 6:54 am Reply with quote
Guest
It seems like your module name doesn't match the table name. If you
want the table name to be different from the module name, you need to
add the following line to the module:

table() -> TableName.

Yariv

On Mon, Jun 23, 2008 at 10:06 PM, harsha <Harsha.Ch@gmail.com> wrote:
>
>
> The erlydb.erl is complaining that the filename we pass as a invalid
> module
> debug:erlydb:405: Error: {error,{invalid_module,
> [116,101,115,116,46,101,114,108]}}
> debug:erlydb:364: calling gen_module_code
> [116,101,115,116,46,101,114,108]
>
>
> btw..
> in erlydb.erl at line 404
> Err -
>>
> Err
> i guess we need a debug statement ?
>
>
> On Jun 17, 5:01 pm, db <masterofquesti...@gmail.com> wrote:
>> Absolute path to the file doesn't work either. Here is my table def:
>>
>> CREATE TABLE `simple` (
>>
>> `id` int(11) NOT NULL AUTO_INCREMENT,
>> `username` varchar(200) NOT NULL,
>>
>> PRIMARY KEY (`id`)
>>
>> ) ENGINE=Innodb DEFAULT CHARSET=latin1;
>>
>> 11> erlydb:code_gen(["/home/db/project1/src/simple_test.erl"],{mysql,
>> [{allow_unsafe_statements, true}]}, [debug_info]).
>> mysql_conn:426: fetch <<"show tables">> (id <0.81.0>)
>> mysql_conn:426: fetch <<"describe simple">> (id <0.81.0>)
>> debug:erlydb:355:
>>
>> --- To skip foreign key checks, compile with the {skip_fk_checks,
>> true} option
>>
>> ok
>>
>> On Jun 15, 12:39 am, "Yariv Sadan" <yarivsa...@gmail.com> wrote:
>>
>> > Try to pass the absolute path to "simple.erl" to code_gen(). Does that work?
>>
>> > On Mon, Jun 9, 2008 at 12:20 PM, db <masterofquesti...@gmail.com> wrote:
>>
>> > > Mysql database is running and has a schema simple with table simple.
>> > > Started erlydb like here:
>>
>> > > erlydb:start(mysql, [{hostname, "localhost"}, {username, "simple"},
>> > > {password, "12345"}, {database, "simple"}, {pool_size, 10}]).
>>
>> > > Not sure why I don't get the mysql table abstraction file(simple.erl)
>> > > when I execute the following. Also there aren't any error
>> > > messages/logs to look into:
>>
>> > > 3> erlydb:code_gen(["simple.erl"], mysql).
>> > > mysql_conn:426: fetch <<"show tables">> (id <0.81.0>)
>> > > mysql_conn:426: fetch <<"describe simple">> (id <0.81.0>)
>> > > debug:erlydb:355:
>>
>> > > --- To skip foreign key checks, compile with the {skip_fk_checks, true} option
>>
>> > > --
>> > > rk
>>
>> > > That which we persist in doing becomes easier for us to do; not that
>> > > the nature of the thing itself is changed, but that our power to do is
>> > > increased.
>> > > -Ralph Waldo Emerson
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist
Guest
Posted: Wed Jun 25, 2008 8:02 pm Reply with quote
Guest
I created a module simple.erl in following folder
/home/db/project1/src/simple.erl and added the following content:

-module(simple).
%-export([table/0]).
%table()-> simple.

Then on erl shell I started the following:

erlydb:start(mysql, [{hostname, "localhost"}, {username, "simple"},
{password, "simple"}, {database, "simple"}, {pool_size, 10}]).

erlydb:code_gen(["/home/db/project1/src/simple.erl"],{mysql,
[{allow_unsafe_statements, true}]}, [debug_info]).

After erlydb:code_gen, I don't see anything written to simple.erl.
Content of simple.erl is still:

-module(simple).
%-export([table/0]).
%table()-> simple.



On Jun 25, 2:53 am, "Yariv Sadan" <yarivsa...@gmail.com> wrote:
> It seems like your module name doesn't match the table name. If you
> want the table name to be different from the module name, you need to
> add the following line to the module:
>
> table() -> TableName.
>
> Yariv
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist
Guest
Posted: Wed Jun 25, 2008 9:02 pm Reply with quote
Guest
Right, the code is actually generated in memory and then compiled into
a .beam file which is the loaded into the VM. You can tell
erlydb:compile() to save the .beam file in a given directory using the
'{outdir, Dir}' option. There's also an option to output the new file
in source form but I don't remember exactly what it is. It should be
in the smerl documentation.

Yariv

On Wed, Jun 25, 2008 at 1:01 PM, db <masterofquestions@gmail.com> wrote:
>
> I created a module simple.erl in following folder
> /home/db/project1/src/simple.erl and added the following content:
>
> -module(simple).
> %-export([table/0]).
> %table()-> simple.
>
> Then on erl shell I started the following:
>
> erlydb:start(mysql, [{hostname, "localhost"}, {username, "simple"},
> {password, "simple"}, {database, "simple"}, {pool_size, 10}]).
>
> erlydb:code_gen(["/home/db/project1/src/simple.erl"],{mysql,
> [{allow_unsafe_statements, true}]}, [debug_info]).
>
> After erlydb:code_gen, I don't see anything written to simple.erl.
> Content of simple.erl is still:
>
> -module(simple).
> %-export([table/0]).
> %table()-> simple.
>
>
>
> On Jun 25, 2:53 am, "Yariv Sadan" <yarivsa...@gmail.com> wrote:
>> It seems like your module name doesn't match the table name. If you
>> want the table name to be different from the module name, you need to
>> add the following line to the module:
>>
>> table() -> TableName.
>>
>> Yariv
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist
Guest
Posted: Wed Jun 25, 2008 9:03 pm Reply with quote
Guest
Btw, after you call erlydb:code_gen(), you can start calling the
generated functions in 'simple', e.g. simple:find_all(), assuming you
didn't restart the VM.

Yariv

On Wed, Jun 25, 2008 at 2:01 PM, Yariv Sadan <yarivsadan@gmail.com> wrote:
> Right, the code is actually generated in memory and then compiled into
> a .beam file which is the loaded into the VM. You can tell
> erlydb:compile() to save the .beam file in a given directory using the
> '{outdir, Dir}' option. There's also an option to output the new file
> in source form but I don't remember exactly what it is. It should be
> in the smerl documentation.
>
> Yariv
>
> On Wed, Jun 25, 2008 at 1:01 PM, db <masterofquestions@gmail.com> wrote:
>>
>> I created a module simple.erl in following folder
>> /home/db/project1/src/simple.erl and added the following content:
>>
>> -module(simple).
>> %-export([table/0]).
>> %table()-> simple.
>>
>> Then on erl shell I started the following:
>>
>> erlydb:start(mysql, [{hostname, "localhost"}, {username, "simple"},
>> {password, "simple"}, {database, "simple"}, {pool_size, 10}]).
>>
>> erlydb:code_gen(["/home/db/project1/src/simple.erl"],{mysql,
>> [{allow_unsafe_statements, true}]}, [debug_info]).
>>
>> After erlydb:code_gen, I don't see anything written to simple.erl.
>> Content of simple.erl is still:
>>
>> -module(simple).
>> %-export([table/0]).
>> %table()-> simple.
>>
>>
>>
>> On Jun 25, 2:53 am, "Yariv Sadan" <yarivsa...@gmail.com> wrote:
>>> It seems like your module name doesn't match the table name. If you
>>> want the table name to be different from the module name, you need to
>>> add the following line to the module:
>>>
>>> table() -> TableName.
>>>
>>> Yariv
>>>
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum