Anyone know of a Ruby SQL parser?
Here's an example of a SQL parser done with rparsec:
http://docs.codehaus.org/display/JPARSEC/SQL+parser+in+rparsec
this is the svn tree for a sql parser based on Treetop
I post answer here for someone who will need. I found this gem 'sql-parser'
gem install sql-parser
However this gem is not up-to-date if you install with command 'gem install'. So we have to check out the code from github also to get latest version. When I try to parse an insert statement after gem install. It failed.
After updating code from github. it can parse.
Github
https://github.com/cryodex/sql-parser
Try the gda gem by tenderlove.
RubyGems: https://rubygems.org/gems/gda
Github: https://github.com/tenderlove/gda/
Related
I am trying to use devise_invitable(0.1.3) in my application and my application already uses devise(3.1.0). I specified the devise_invitable in my gem file and run bundle install it installed successfully but when i run any command it gives the following error:
Error:
uninitialized constant DeviseMailer (NameError)
Can anyone tell what i am doing wrong?
Any help would be appreciated.
Thank You
Per the devise_invitable README, you need to be using the version straight from github if you are on Rails 4:
gem 'devise_invitable', :github => 'scambra/devise_invitable'
I am trying to use the gem gchartrb to create some graphs/charts in my RoR application.
I have looked into several tutorial and all say the same thing, that I have to add
require 'google_chart'
But I am getting the message:
no such file to load -- google_chart
I have the require inside my controller, I have confirmed that the gem is installed.
I am using Rails 3.
Also, I have tried adding config.gem 'gchartrb', :lib => 'google_chart' in my environment.rb as suggested here but nothing changed
Thanks for your help
EDIT:
I have also tried with the gem googlecharts, what I have in my Gemfile is:
gem "googlecharts", :require => "gchart"
but I get no such file to load -- gchart when I try to load the view.
I am not sure, it is required now or not. But it worked for me in Rails 3 as well. I am using Rails 3.0.10. I added below 2 lines and it worked for me.
1) gem 'gchartrb' in Gemfile
2) require 'google_chart' in config/boot.rb
Hope it helps!
config.gem is for rails 2.3.X.
For rails 3, you will need to add the gem to your Gemfile and run gem bundle
You may also need to check that the google_charts gem actually supports Rails 3...
Given that the latest code update seems to have been in 2008 - that might not actually be likely. :(
You can try it anyway and see...
i currently try to import some XML via XMLSimple in my RoR-3 App.
on 1 position, that XML stores a YAML-Structure. Dont slap me, i did not create the xml ;)
now that i have it stored in a variable, lets say yamldata, i want to parse its content.
so i do:
chunks = YAML::load yamldata
and thats pretty it.
when i now echo these chunks-values to console, it get this:
Bülach vert
what i wanted to have is:
Bülach vert
when i use exact same sourcecode in IRB, i actually get this 'ü' instead of 'ü'.
i really dont know what to do here.
my Gemfile:
cat Gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.0'
gem 'mysql2'
gem 'haml'
gem 'activerecord', :require => "active_record"
gem 'xml-simple'
gem 'hpricot'
ruby -v:
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
i`d be happy with any idea.
Note: i echo these values before!! i store them into a model, so i guess that its not a sql-related issue - however, db-encoding is utf8 too.
any idea? Thanks!
thanks to the helpers! :)
i found that irb does use Syck, rails Psych.
so i guess this is the main difference... will research more..
SOLUTION:
require 'yaml'
YAML::ENGINE.yamler= 'syck'
into boot.rb and BAM!
Maybe this answer can help you:
Ruby on Rails 3, incompatible character encodings: UTF-8 and ASCII-8BIT with i18n
He states that he could solve a similar problem by configuring this:
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
on config/environment.rb
Hope that helps.
I have a question about what is probably a gems problem, but may be meta-where. I used gems to install meta_where-1.0.4, and the response was that I succeeded and the uri for meta_where was provided, but when I tried a where-condition in the search method of a controller, similar to this example that meta-where provides:
Person.where(:skill_set.matches => 'Hello%'
an error was reported:
"undefined method 'matches' for :skill_set:Symbol"
It's as if the gem's methods aren't being accessed. I tried using "require" but that didn't help.
I'm using Windows XP, Firefox, Ruby 1.9.2.
What do I need to do?
Thanks, Barney
I assume you have run the migrations and there is a skill_set attribute in the person table: you don't need require. Just add 'gem meta_where' to your Gemfile and then run 'bundle install'.
I use rails 3.
In development mode I installed some gems for Testing (diff-lcs, nokogiri, rspec, webrat).
Since I did that, if I try to cap-deploy to the production server, it complains:
"Could not find diff-lcs in any of the sources (Bundler::GemNotFound)"
I don't want to install them on the server, because I don't need the testing purpose gems on the production server.
Can I put something in the Gemfile to maybe exclude them for production mode?
Or else how can I handle this?
Thank you very much for answering this questiion by a struggling beginner...
You can put those gems in their own group like this:
group :development, :test do
gem 'diff-lcs'
end
This page explains groups in more details: http://gembundler.com/groups.html