我想为我数据库中的所有表创建按钮(使用 Shoes)。
我是初学者,这是我的第一个 GUI 项目“库存管理”,我正在使用 Ruby 中的鞋子库,并希望使用 Ruby 在 MySql2 中存储和管理数据。我输入了一些代码,但它不起作用
路径/main.rb
require 'mysql2'
require 'green_shoes'
client = Mysql2::Client.new (host: "localhost",username: "root", password: "xyz", database: "Ruby")
Shoes.app do
components = client.query("SHOW TABLES")
components.each do |item|
button item
end
end`
什么都不给。
最佳答案
您可以从 information_schema
查询它们:
components = client.query("SELECT table_name FROM information_schema.tables")
关于mysql - 如何在 Ruby 的 MySql2 中打印数据库中所有表的名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47853556/