Database connection from a module using a yml file

View: New views
5 Messages — Rating Filter:   Alert me  

Database connection from a module using a yml file

by Philipp Marcus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I`m developing a RubyAstRule module for Ruby on Rails development. My
module needs to connect to the database, specified in the database.yml
of the opened ruby on rails project. I`ve seen that there are a lot of
classes concerning database connections in the package
org.netbeans.modules.ruby.railsprojects.database.
Can I use these classes to parse a given yml file and get the stuff I
need to establish a jdbc connection and read out the database content?
Or do I have to implement it on my own?

Best Regards,
    Philipp Marcus

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Database connection from a module using a yml file

by Tor Norbye :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sep 18, 2008, at 7:45 AM, Philipp Marcus wrote:

> Hi,
>
> I`m developing a RubyAstRule module for Ruby on Rails development.  
> My module needs to connect to the database, specified in the  
> database.yml of the opened ruby on rails project. I`ve seen that  
> there are a lot of classes concerning database connections in the  
> package org.netbeans.modules.ruby.railsprojects.database.

To parse YAML you'll probably want to use the jvyamlb parser we're  
also using for the YAML editor language plugin (languages.yaml).  You  
can find jvyamlb in "libs.jvyamlb". For the editor we're running the  
parser in a special mode such that it produces AST nodes for the YAML  
(with position info etc) but you just need it to do plain YAML parsing  
to produce lists, maps, etc containing the data.

Once you have the YAML data parsed, I guess you need to do some  
database stuff and for that I'll defer to Erno or David who know about  
the database package in the rails project (though I think Erno may be  
on vacation, so I'm cc'ing David).

-- Tor

>
> Can I use these classes to parse a given yml file and get the stuff  
> I need to establish a jdbc connection and read out the database  
> content? Or do I have to implement it on my own?
>
> Best Regards,
>   Philipp Marcus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@...
> For additional commands, e-mail: dev-help@...
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Database connection from a module using a yml file

by David Van Couvering :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, Philipp.  There is a whole API that lets you work with database
connections called the Database Explorer API.

For the latest docs, see
http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-db/overview-summary.html

If you have any questions, let me know, or better yet send them to
dev@....

David

Tor Norbye wrote:

>
> On Sep 18, 2008, at 7:45 AM, Philipp Marcus wrote:
>
>> Hi,
>>
>> I`m developing a RubyAstRule module for Ruby on Rails development. My
>> module needs to connect to the database, specified in the
>> database.yml of the opened ruby on rails project. I`ve seen that
>> there are a lot of classes concerning database connections in the
>> package org.netbeans.modules.ruby.railsprojects.database.
>
> To parse YAML you'll probably want to use the jvyamlb parser we're
> also using for the YAML editor language plugin (languages.yaml).  You
> can find jvyamlb in "libs.jvyamlb". For the editor we're running the
> parser in a special mode such that it produces AST nodes for the YAML
> (with position info etc) but you just need it to do plain YAML parsing
> to produce lists, maps, etc containing the data.
>
> Once you have the YAML data parsed, I guess you need to do some
> database stuff and for that I'll defer to Erno or David who know about
> the database package in the rails project (though I think Erno may be
> on vacation, so I'm cc'ing David).
>
> -- Tor
>
>>
>> Can I use these classes to parse a given yml file and get the stuff I
>> need to establish a jdbc connection and read out the database
>> content? Or do I have to implement it on my own?
>>
>> Best Regards,
>>   Philipp Marcus
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@...
>> For additional commands, e-mail: dev-help@...
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@...
> For additional commands, e-mail: dev-help@...
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Database connection from a module using a yml file

by Philipp Marcus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

thanks for your help! In order to get the jvyamlb parser working I`d
need some examples on how to use it`s api. You`ve mentioned that you use
it for the yaml editor. Where can I find this editor? I hope I can get
some inspiration from it.
Best Regards,

    Philipp Marcus

>
> On Sep 18, 2008, at 7:45 AM, Philipp Marcus wrote:
>
>> Hi,
>>
>> I`m developing a RubyAstRule module for Ruby on Rails development. My
>> module needs to connect to the database, specified in the
>> database.yml of the opened ruby on rails project. I`ve seen that
>> there are a lot of classes concerning database connections in the
>> package org.netbeans.modules.ruby.railsprojects.database.
>
> To parse YAML you'll probably want to use the jvyamlb parser we're
> also using for the YAML editor language plugin (languages.yaml).  You
> can find jvyamlb in "libs.jvyamlb". For the editor we're running the
> parser in a special mode such that it produces AST nodes for the YAML
> (with position info etc) but you just need it to do plain YAML parsing
> to produce lists, maps, etc containing the data.
>
> Once you have the YAML data parsed, I guess you need to do some
> database stuff and for that I'll defer to Erno or David who know about
> the database package in the rails project (though I think Erno may be
> on vacation, so I'm cc'ing David).
>
> -- Tor
>
>>
>> Can I use these classes to parse a given yml file and get the stuff I
>> need to establish a jdbc connection and read out the database
>> content? Or do I have to implement it on my own?
>>
>> Best Regards,
>>   Philipp Marcus
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@...
>> For additional commands, e-mail: dev-help@...
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@...
> For additional commands, e-mail: dev-help@...
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Database connection from a module using a yml file

by Tor Norbye :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sep 21, 2008, at 5:39 AM, Philipp Marcus wrote:

> Hi,
>
> thanks for your help! In order to get the jvyamlb parser working I`d  
> need some examples on how to use it`s api. You`ve mentioned that you  
> use it for the yaml editor. Where can I find this editor? I hope I  
> can get some inspiration from it.

Look at languages.yaml/ -- the jvyamlb parser is invoked from  
YamlParser.java. Note however that this will drive the parser in AST-
mode, and I'm also walking through the result as AST nodes.

Take a look at the README for jvyamlb:
http://github.com/olabini/jvyamlb/tree/master/README

As you can see invoking the parser is trivial, and what you end up  
with are simple java.util Collections objects (Maps, Lists, etc.).

-- Tor


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...