简体   繁体   English

未初始化的常量Mysql

[英]Uninitialized constant Mysql

I'm working on a web service to access my database via mysql, but I keep getting this error : NameError - uninitialized constant Mysql 我正在使用Web服务通过mysql访问我的数据库,但我不断收到此错误:NameError-未初始化的常量Mysql

When I created the Database, i did not add a password to it. 创建数据库时,我没有向其添加密码。 I am using Microsoft SQL Management Studio. 我正在使用Microsoft SQL Management Studio。 To test the web service i am using Advanced REST client. 要测试Web服务,我正在使用高级REST客户端。

This is my code 这是我的代码

get '/all_users/' do
conn=Mysql.new('localhost','My-PC\Nikki','', 'My-PC\Project')
recordsArray = "{\"clientList\":["
clientArray = Array.new
sql = 'select * from ServerUsers'
records = conn.do(sql) do |record|
    client = AndroidtableClientsSearch.new(record[0],record[1],record[2],record[3], record[4])
    clientArray<<client.to_s
end
conn.logoff
recordsArray<<clientArray.join(',')
recordsArray<<"]}"
recordsArray
end

I got the same error. 我遇到了同样的错误。 You also need to install the mysql gem. 您还需要安装mysql gem。 Running 'gem install mysql' fixed this for me. 运行'gem install mysql'可以解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM