run sql commands from a batch file

run sql commands from a batch file

am 22.11.2004 14:14:21 von mailinglists1

Hi,

for testing purposes I want to execute a bat file to delete all table
entries. Here is my bat file:

REM Delete all table entries from mytestdbhibi (MySQL)

@echo off

mysql --user=asdf --password=xxxx --database=mytestdbhibi

truncate table player;
truncate table team_manager;
truncate table person;
truncate table address;
truncate table team;

exit

This script does not work. When I execute the file, only the mysql line is
processed and I see the mysql prompt. How I have to fix this, so the sql
commands are also processed?

Thx,
Dirk


--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org

Re: run sql commands from a batch file

am 22.11.2004 14:54:34 von Daniel da Veiga

Hi Dirk,

You can create a file, lets say "mycommands.sql" and put all your
truncate commands inside it, as you did in your batch file, and then
direct the file as input for the console like this:

mysql --user=asdf --password=xxxx --database=mytestdbhibi < mycoomands.sql

So, yout bat file will only have this command.

OBS: I am not sure, but I think the "exit" command is unnecessary when
using sql files this way :)

On Mon, 22 Nov 2004 14:14:21 +0100, Dirk (Mailing list)
wrote:
> Hi,
>
> for testing purposes I want to execute a bat file to delete all table
> entries. Here is my bat file:
>
> REM Delete all table entries from mytestdbhibi (MySQL)
>
> @echo off
>
> mysql --user=asdf --password=xxxx --database=mytestdbhibi
>
> truncate table player;
> truncate table team_manager;
> truncate table person;
> truncate table address;
> truncate table team;
>
> exit
>
> This script does not work. When I execute the file, only the mysql line is
> processed and I see the mysql prompt. How I have to fix this, so the sql
> commands are also processed?
>
> Thx,
> Dirk
>
> --
> MySQL Windows Mailing List
> For list archives: http://lists.mysql.com/win32
> To unsubscribe: http://lists.mysql.com/win32?unsub=danieldaveiga@gmail.com
>
>


--
Daniel da Veiga
Computer Operator - RS - Brazil

--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org

AW: run sql commands from a batch file

am 22.11.2004 15:01:19 von mailinglists1

thanks for helping me. the exit command is processed automatically in =
this
case, so it can be omitted.

-----Ursprüngliche Nachricht-----
Von: Daniel da Veiga [mailto:danieldaveiga@gmail.com]=20
Gesendet: Montag, 22. November 2004 14:55
An: win32@lists.mysql.com
Betreff: Re: run sql commands from a batch file

Hi Dirk,

You can create a file, lets say "mycommands.sql" and put all your =
truncate
commands inside it, as you did in your batch file, and then direct the =
file
as input for the console like this:

mysql --user=3Dasdf --password=3Dxxxx --database=3Dmytestdbhibi < =
mycoomands.sql

So, yout bat file will only have this command.

OBS: I am not sure, but I think the "exit" command is unnecessary when =
using
sql files this way :)

On Mon, 22 Nov 2004 14:14:21 +0100, Dirk (Mailing list)
wrote:
> Hi,
>=20
> for testing purposes I want to execute a bat file to delete all table=20
> entries. Here is my bat file:
>=20
> REM Delete all table entries from mytestdbhibi (MySQL)
>=20
> @echo off
>=20
> mysql --user=3Dasdf --password=3Dxxxx --database=3Dmytestdbhibi
>=20
> truncate table player;
> truncate table team_manager;
> truncate table person;
> truncate table address;
> truncate table team;
>=20
> exit
>=20
> This script does not work. When I execute the file, only the mysql=20
> line is processed and I see the mysql prompt. How I have to fix this,=20
> so the sql commands are also processed?
>=20
> Thx,
> Dirk
>=20
> --
> MySQL Windows Mailing List
> For list archives: http://lists.mysql.com/win32
> To unsubscribe:
http://lists.mysql.com/win32?unsub=3Ddanieldaveiga@gmail.com
>=20
>=20


--
Daniel da Veiga
Computer Operator - RS - Brazil

--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: =
http://lists.mysql.com/win32?unsub=3Dmailinglists1@arcor.de


--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=3Dgcdmw-win32@m.gmane.org

Re: run sql commands from a batch file

am 22.11.2004 18:26:17 von agarrammone

Hi Dirk...well, you have to do another file *.sql or whatever with the sql
statements.
In your batch file, you do the following:
> mysql --user=asdf --password=xxxx --database=mytestdbhibi

I think with this you can resolve the problem

Best regards,

Alex

PD: Maybe the ">" it's not neccesary because this is usefull when you
redirect to a .txt file if you want to query a database. Try with and
without it.

----- Original Message -----
From: "Dirk (Mailing list)"
To:
Sent: Monday, November 22, 2004 10:14 AM
Subject: run sql commands from a batch file


> Hi,
>
> for testing purposes I want to execute a bat file to delete all table
> entries. Here is my bat file:
>
> REM Delete all table entries from mytestdbhibi (MySQL)
>
> @echo off
>
> mysql --user=asdf --password=xxxx --database=mytestdbhibi
>
> truncate table player;
> truncate table team_manager;
> truncate table person;
> truncate table address;
> truncate table team;
>
> exit
>
> This script does not work. When I execute the file, only the mysql line is
> processed and I see the mysql prompt. How I have to fix this, so the sql
> commands are also processed?
>
> Thx,
> Dirk
>
>
> --
> MySQL Windows Mailing List
> For list archives: http://lists.mysql.com/win32
> To unsubscribe:
http://lists.mysql.com/win32?unsub=agarrammone@afip.gov.ar
>



--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org

RE: run sql commands from a batch file

am 22.11.2004 23:17:32 von jbonnett

One technique you can use if you want to keep eveything in one file is
like this.

@echo off
echo truncate table player; >temp.sql
echo truncate table team_manager; >>temp.sql
echo truncate table person; >>temp.sql=20
echo truncate table address; >>temp.sql
echo truncate table team; >>temp.sql=20
mysql --user=3Dasdf --password=3Dxxxx --database=3Dmytestdbhibi =
del temp.sql

John Bonnett

-----Original Message-----
From: Dirk (Mailing list) [mailto:mailinglists1@arcor.de]=20
Sent: Monday, 22 November 2004 11:44 PM
To: win32@lists.mysql.com
Subject: run sql commands from a batch file


Hi,

for testing purposes I want to execute a bat file to delete all table
entries. Here is my bat file:

REM Delete all table entries from mytestdbhibi (MySQL)

@echo off

mysql --user=3Dasdf --password=3Dxxxx --database=3Dmytestdbhibi=20

truncate table player;=20
truncate table team_manager;=20
truncate table person;=20
truncate table address;
truncate table team;=20

exit

This script does not work. When I execute the file, only the mysql line
is processed and I see the mysql prompt. How I have to fix this, so the
sql commands are also processed?

Thx,
Dirk=20


--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=3Dgcdmw-win32@m.gmane.org