2
I need to open a file. txt whatever has a string sequence separated by ";" and needs to be placed each ";" on a vector to then create a loop and insert it into the database.
What do I have:
require 'pg'
require 'active_record'
= File.open('teste.txt')
f_lines = f.read.split(";")
Connection to the bank
conn = ActiveRecord::Base.establish_connection(:adapter => 'postgresql',
:username => 'root',
:password => "123",
:host => "127.0.0.1",
:database => "db")
#query = "insert into students (name, registration, room, password) values "+ vetor[]
#simulated = ActiveRecord::Base.connection.execute(query)
PS.: My file . txt will have several lines.
Caaaaaaaaaaara, Perfect!!!! Thank you very much, it helped a lot even
– Juliano
Opa que bom que ajudou @Juliano, se a resposta resolver seu problema marque como resposta. Grande abraço. Precisa estamos ai!
– Luiz Carvalho
Boaa @Juliano :D
– Luiz Carvalho