how to create a sql table in ruby code example
Example 1: how to create an SQL table in ruby
def self.create_table
sql = <<-SQL
CREATE TABLE IF NOT EXISTS students (
name TEXT,
grade TEXT
)
SQL
DB[:conn].execute(sql)
end
Example 2: Write SQL in ruby on rails
sql = "Select * from ... your sql query here"
records_array = ActiveRecord::Base.connection.execute(sql)