Answers for "how to define a save method in ruby for sqlite3 databases"

SQL
0

how to define a save method in ruby for sqlite3 databases

def save
    sql = <<-SQL
      INSERT INTO songs (name, album) 
      VALUES (?, ?)
    SQL
 
    DB[:conn].execute(sql, self.name, self.album)
 
    @id = DB[:conn].execute("SELECT last_insert_rowid() FROM songs")[0][0]
 
  end
Posted by: Guest on November-13-2019

Code answers related to "how to define a save method in ruby for sqlite3 databases"

Code answers related to "SQL"

Browse Popular Code Answers by Language