Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
import txt file to mysql with ruby & load data local ??
Mike Turco
8/24/2006 6:27:00 PM
I'm trying to run this sql from within a ruby program
LOAD DATA LOCAL INFILE 'C:\\test.txt' INTO TABLE `links` FIELDS
TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY
'\r\n'
will this even work with ruby? what should syntax be?
require "rubygems"
require "mysql"
begin
dbName = "testdb"
m = Mysql.new("localhost", "root", "")
m.select_db(dbName)
result = m.query(???)
puts "done"
end
??
--
Posted via
http://www.ruby-...
.
1 Answer
Paul Lutus
8/24/2006 8:32:00 PM
0
Mike Turco wrote:
> I'm trying to run this sql from within a ruby program
>
> LOAD DATA LOCAL INFILE 'C:\\test.txt' INTO TABLE `links` FIELDS
> TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY
> '\r\n'
> will this even work with ruby?
Yes, if it will work with MySQL directly, it should work here as well.
> what should syntax be?
It should be valid MySQL syntax. Why not do some experiments?
If you have valid MySQL strings, strings that created what you expected from
past experience, those strings will work here as well.
You can always test your syntax in advance using the command-line mysql
interface:
$ echo "string of MySQL commands;" | mysql -u $USER -p (password)
Basically, this question is more about MySQL than it is about Ruby. Chances
are your valid strings will work with Ruby's MySQL interface.
Maybe some experimentation is in order.
--
Paul Lutus
http://www.ara...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
import txt file to mysql with ruby & load data local ??
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password