简体   繁体   中英

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

When I created the Database, i did not add a password to it. I am using Microsoft SQL Management Studio. To test the web service i am using Advanced REST client.

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. Running 'gem install mysql' fixed this for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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