Re: lug-bg: mySQL i bash script
- Subject: Re: lug-bg: mySQL i bash script
- From: danail@xxxxxxxxxxxxx (Danail Ninov)
- Date: Wed, 3 Apr 2002 11:19:20 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
datebegin=`date +%Y%m01`
dateend=`date +%Y%m%d2359`
ql="SELECT name, start_time as start, stop_time as end,
SEC_TO_TIME(time_on) as time_on FROM usertime WHERE
usertime.start_time>=$datebegin AND usertime.start_time<=$dateend AND
usertime.name=\"$1\";"
sql1="SELECT name, SEC_TO_TIME(sum(time_on)) as time_on FROM usertime
WHERE usertime.start_time>=$datebegin AND
usertime.start_time<=$dateend AND usertime.name=\"$1\" GROUP by
name;"
echo $sql | mysql database
echo $sql1 | mysql database
Estestveno "mysql database" triabva da byde s opciite koito polzvash
ako ne sa zapisani v .my.cnf
- ----- Original Message ----- .my.cnf
From: "Dimitar Peikov" <mitko@xxxxxxx>
To: <lug-bg@xxxxxxxxxxxxxxxxxx>
Sent: Wednesday, April 03, 2002 8:54 AM
Subject: Re: lug-bg: mySQL i bash script
>
> mysql -u username -ppassword database -e "show tables"
>
>
>
> On Tue, 02 Apr 2002 19:23:38 -0500
> Delyan Raychev <draychev@xxxxxx> wrote:
>
> > E neka da ne e bash a perl. Mozhe li?
> > Ako imash perl - eto neshto lesno...
> >
> > use DBI;
> >
> > my $dbh = DBI->connect('DBI:MySQL:DataBase')
> > or die "Couldn't connect to database: " .
> > DBI->errstr;
> > my $sth = $dbh->prepare('SELECT * FROM people WHERE
> > lastname =
> > ?') or die "Couldn't prepare statement: " .
> > $dbh->errstr;
> >
> >
> > $sth->execute($lastname) # Execute the
> > query
> > or die "Couldn't execute statement: " . $sth->errstr;
> >
> > # Read the matching records and print them out
> >
> > while (@data = $sth->fetchrow_array()) {
> > my $firstname = $data[1];
> > my $id = $data[2];
> > }
> >
> > $sth->finish;
> >
> > }
> >
> > $dbh->disconnect;
> >
> > Upseh!
> >
> > Delyan Raychev
> > draychev@xxxxxx
> >
> > Konstantin Ivanov wrote:
> >
> > >Kak moga da napisha bash script s koito da pravia query-ta v
> > >mysql baza danni, syshtoto sam go postignal s PGP prez web, no
> > >ne mi e mnogo iasno kak da stane sys shell komandi.
> > >
> >
>
>
> --
> Dimitar Peikov
> Programmer Analyst
> Globalization Group
> "We Build e-Business"
>
> RILA Solutions
> 27 Building, Acad.G.Bonchev Str.
> 1113 Sofia, Bulgaria
>
> phone: (+359 2) 9797320
> phone: (+359 2) 9797300
> fax: (+359 2) 9733355
> http://www.rila.com
> ====================================================================
> ======= A mail-list of Linux Users Group - Bulgaria (bulgarian
> linuxers)
> http://www.linux-bulgaria.org/ Hosted by Internet Group Ltd. -
> Stara Zagora
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPKrJEedTpC1E7/FpEQIhEQCcCdR1YQqaZezDBfVtqygCUKleluoAoLpL
XWr2NSa4Ho0HS49U3svAkDa+
=pigc
-----END PGP SIGNATURE-----
===========================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers)
http://www.linux-bulgaria.org/ Hosted by Internet Group Ltd. - Stara Zagora
|