--------------enigC2D64F734A2CC3FD45B7EE52
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Park Heesob wrote:
>> I'm trying to use the mysql 'source' command within a ruby script to r=
un
>> a batch file, but it doens't seem to work.  When I run the source
>> command straight from mysql, though, it runs just fine.  Here's a shor=
t
>> example of what I'm trying to do:
>>
>> Anyone have any ideas?  Thanks in advance.
>>
>=20
> 'source' is not an SQL command, but an internal command of the mysql
> command line client.
>=20
> You could use Ruby's system like this:
>=20
> system("/path/to/mysql -uuser -ppassword database <#{filename}");
>=20

That presumes the ruby script and the SQL script are colocated (and this
being MySQL, if my assumptions on users of that product hold, the
database server will also be on the same machine).

In that case, you can also read the file inside the Ruby process and
then feed the commands to the database connection. This has the
advantage that you don't show your DB username and password to all and
sundry connected to that machine in ps output. (Passwords on command
lines are bad, 'mmmkay.)

David Vallner


--------------enigC2D64F734A2CC3FD45B7EE52
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)

iD8DBQFFcWMIy6MhrS8astoRApbKAJ4ojQtBDTeCBWULi8RLOWscGhyKIQCggGu1
/I34RqZwxSRLs36FlIHLhIg=
=GrKF
-----END PGP SIGNATURE-----

--------------enigC2D64F734A2CC3FD45B7EE52--