Hi,
How to operate on MySQL? I would like to delete, create database and
upgrade with prepared files. I know mysql library but I'm not sure
whether it let me operate on commands such as delete database, source
file_path etc.
I will be appreciated for any help
MT
···
--
Posted via http://www.ruby-forum.com/.
I would like to delete, create database and
upgrade with prepared files. I know mysql library but I'm not sure
whether it let me operate on commands such as delete database, source
file_path etc.
If you connect with administrator privileges, you should be able
to execute any command you could also execute from the mysql
command line interface.
Ronald
···
--
Ronald Fischer <ronald.fischer@venyon.com>
Phone: +49-89-452133-162
Pretty much all database interfaces allow you to send raw commands.
Such as:
require "mysql"
dbh = Mysql.real_connect("localhost", "testuser", "testpass", "test")
dbh.query("CREATE TABLE test(column VARCHAR(255))")
dbh.query("DROP TABLE IF EXISTS test")
File.open("sql_commands_in_textfile") do |file|
while line = file.gets
dbh.query(line)
end
end
···
-----Original Message-----
From: list-bounce@example.com
[mailto:list-bounce@example.com] On Behalf Of Marcin Tyman
Sent: Thursday, July 26, 2007 4:47 AM
To: ruby-talk ML
Subject: MySQL
Hi,
How to operate on MySQL? I would like to delete, create
database and upgrade with prepared files. I know mysql
library but I'm not sure whether it let me operate on
commands such as delete database, source file_path etc.
I will be appreciated for any help
MT
--
Posted via http://www.ruby-forum.com/\.
You can use Ruby/MySQL, MySQL/Ruby, DBI, or ActiveRecord
~ Ari
English is like a pseudo-random number generator - there are a bajillion rules to it, but nobody cares.
···
On Jul 26, 2007, at 7:47 AM, Marcin Tyman wrote:
Hi,
How to operate on MySQL? I would like to delete, create database and
upgrade with prepared files. I know mysql library but I'm not sure
whether it let me operate on commands such as delete database, source
file_path etc.
I will be appreciated for any help
Ronald Fischer wrote:
I would like to delete, create database and
upgrade with prepared files. I know mysql library but I'm not sure
whether it let me operate on commands such as delete database, source
file_path etc.
If you connect with administrator privileges, you should be able
to execute any command you could also execute from the mysql
command line interface.
Ronald
dbh.query("source c:/create.sql") - doesn't work. It causes SQL syntax.
···
--
Posted via http://www.ruby-forum.com/\.
dbh.query("source c:/create.sql") - doesn't work. It causes
SQL syntax.
True, but for this case, you can always do
IO.readlines("c:/create.sql").each { |s| dbh.query(s) }
Ronald
···
--
Ronald Fischer <ronald.fischer@venyon.com>
Phone: +49-89-452133-162
Ronald Fischer wrote:
dbh.query("source c:/create.sql") - doesn't work. It causes
SQL syntax.
True, but for this case, you can always do
IO.readlines("c:/create.sql").each { |s| dbh.query(s) }
Ronald
Thanks, I'll check it. It seems to be ok. At the moment I cannot check
it (the db is used)
···
--
Posted via http://www.ruby-forum.com/\.
NEVER develop against a live database.
···
-----Original Message-----
From: list-bounce@example.com
[mailto:list-bounce@example.com] On Behalf Of Marcin Tyman
Sent: Thursday, July 26, 2007 5:52 AM
To: ruby-talk ML
Subject: Re: MySQL
Ronald Fischer wrote:
>> dbh.query("source c:/create.sql") - doesn't work. It causes SQL
>> syntax.
>
> True, but for this case, you can always do
>
> IO.readlines("c:/create.sql").each { |s| dbh.query(s) }
>
> Ronald
Thanks, I'll check it. It seems to be ok. At the moment I
cannot check it (the db is used)
--
Posted via http://www.ruby-forum.com/\.
Safest advice, yes, but...
Well, you can, but that's when safety mechanisms like not developing under root or not having all priveledges are good ideas.
It's their database though.
···
On Jul 26, 2007, at 8:06 AM, Felix Windt wrote:
-----Original Message-----
From: list-bounce@example.com
[mailto:list-bounce@example.com] On Behalf Of Marcin Tyman
Sent: Thursday, July 26, 2007 5:52 AM
To: ruby-talk ML
Subject: Re: MySQL
Ronald Fischer wrote:
dbh.query("source c:/create.sql") - doesn't work. It causes SQL
syntax.
True, but for this case, you can always do
IO.readlines("c:/create.sql").each { |s| dbh.query(s) }
Ronald
Thanks, I'll check it. It seems to be ok. At the moment I
cannot check it (the db is used)
--
Posted via http://www.ruby-forum.com/\.
NEVER develop against a live database.