Processing MySQL result in bash

后端 未结 3 326
抹茶落季
抹茶落季 2021-01-22 07:05

I\'m currently having a already a bash script with a few thousand lines which sends various queries MySQL to generate applicable output for munin.

Up until now the resul

3条回答
  •  后悔当初
    2021-01-22 07:30

    You're going to "fork out," as you put it, to the mysql command line client program anyhow. So either way you're going to have process-creation overhead. With your approach of using a new invocation of mysql for each query you're also going to incur the cost of connecting to and authenticating to the mysqld server multiple times. That's expensive, but the expense may not matter if this app doesn't scale up.

    Making it secure against sql injection is another matter. If you prompt a user for her name and she answers "sally;drop table type;" she's laughing and you're screwed.

    You might be wise to use a language that's more expressive in the areas that are important for data-base access for some of your logic. Ruby, PHP, PERL are all good choices. PERL happens to be tuned and designed to run snappily under shell script control.

提交回复
热议问题