如何在Ruby中的MySql2中打印数据库中所有表的名称?

问题描述 投票:1回答:1

我想创建数据库中所有表的按钮(使用Shoes)。

我是初学者,这是我的第一个GUI项目'Stock Management',我在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`

什么都不给。

mysql ruby database green-shoes
1个回答
0
投票

你可以从information_schema查询它们:

components = client.query("SELECT table_name FROM information_schema.tables")
© www.soinside.com 2019 - 2024. All rights reserved.