I too am a Java guy. The nice part of Java is that it's cross platform and cross database. Using JDBC and pure java JDBC drivers you can move your applications to different databases on just about any relevant platform. This will allow you to run your java applications on Windows, Mac, Linux, Solaris and many others. If you wanted a simple scripting language you could use the Rhino project from Mozilla and create a basic java application that launches java script giving you a true scripting language that can access all the goodness of java.

From what I understand there are many possibilities outside of java such as perl, ruby, python and others.

I'm partial to Java but more than that I'm a big believer in cross platform solutions. I don't believe you should ever tell a customer what to use, they should tell you what they want to use. Which accounts for my motivation to suggest cross platform scripting/language solutions.

Joe

On Thursday, March 4, 2004, at 10:25 AM, Victor Medina wrote:

HI!

ODBC is a nice, cheap and easy way. JDBC is a nice option also (i am a
java guy, forgive me! =)

There are a few utilities around that may help, including some gui
managers for mysql, better yet, sitted behind your comfortable windows
desktop =)

A few utilities to try:

sqlyog: www.sqlyog.com
dbtools: www.dbtools.com.br

Best Regards!

On Thu, 2004-03-04 at 11:11, HACKATHORN, TODD (SWBT) wrote:

I think that will help, I'll give it a try, I have had a lot of trouble
finding good tutorials for bash also. Having been a windows person for so
long it seems very foreign to me. I see how you connect to the local data
base, does anyone know how to import data from another non mySQL database
server? To make two connections and pull data from one to the other?


Thanks,

Todd Hackathorn


-----Original Message----- From: Rhino [mailto:[EMAIL PROTECTED] Sent: Thursday, March 04, 2004 8:30 AM To: HACKATHORN, TODD (SWBT); [EMAIL PROTECTED] Subject: Re: Scripting

Todd,

I'm also pretty new to MySQL and Linux but I have years of DB2 experience on
various platforms.


I've bash scripts very useful and cron them when I have something that I
want to automate, such as a daily backup of my databases. Here are some
examples of bash scripts that I use with MySQL.


This example, which is in file RI.sql, creates two related tables in the
MySQL 'tmp' database, populates them, and displays the results. NOTE: The
'Another Mistake' row will not be successfully inserted into the 'emp' table
because it has an invalid foreign key; there is no row for dept 'X99' in the
'dept' table.


---

use tmp;

drop table if exists dept;
create table dept(
deptno char(3) not null,
deptname varchar(36) not null,
mgrno char(6),
primary key(deptno)
) Type=InnoDB;

drop table if exists emp;
create table emp(
empno char(6) not null,
firstnme char(12) not null,
midinit char(1),
lastname char(15) not null,
workdept char(3) not null,
salary dec(9,2) not null,
primary key(empno),
index(workdept),
foreign key(workdept) references dept(deptno) on delete restrict
) Type=InnoDB;

insert into dept values
('A00', 'Administration', '000010'),
('D11', 'Manufacturing', '000020'),
('E21', 'Education', '000030');

insert into emp values ('000010', 'Christine', 'I', 'Haas','A00',50000.00);
insert into emp values ('000020', 'George', 'W', 'Bush', 'D11', 30000.00);
insert into emp values ('000030', 'Another', ' ', 'Mistake', 'X99',
15000.00);
insert into emp values ('000040', 'John', ' ', 'Kerry', 'E21', 35000.00);


select * from dept;

select * from emp;

---

You can run the preceding script from the mysql prompt by preceding its name
with '\.'. For example:


mysql> \. RI.sql


This script, called backup2.bash, is what I use to back up my databases each
night. It includes a comment showing the crontab entry I use to run it.
NOTE: We are using a Perl package called 'sendEmai'l instead of the
traditional 'sendmail' program.


---
#!/bin/bash

#This script makes a separate database-level backup of each of the current
MySQL databases and
#deletes backups older than a certain number of days.
#This script is normally invoked via a cron job so that it runs once per day
in the middle of the night.
#The crontab entry looks like this:
#0 3 * * * sh /home/rhino/MySQL/backup2.bash > /home/rhino/MySQL/backup2.out
2>&1; cat /home/rhino/MySQL/backup2.out | sendEmail -f [EMAIL PROTECTED] -t
[EMAIL PROTECTED] -u "Daily Backup Report"


USERID="foo"; #The userid to use for creating the backup
PASSWORD="foopass"; #The password to use for creating the backup
BACKUP_TIMESTAMP=`/bin/date +%Y%m%d"-"%H%M%S`; #The timestamp
(YYYYMMDD-HHMMSS) of the backup
BACKUP_PATH="/home/rhino/MySQL/backup"; #The directory into which the backup
will be written
NUMBER_OF_DAILY_BACKUPS_TO_KEEP=7; #The number of generations of backups to
keep


echo "** REPORT BEGINS **";
echo
echo "Program Name:" $0
report_date=`/bin/date`
echo "Report Date:" $report_date;
echo

#Display the non-secret values used in this run.
echo "Backup Values:";
echo " Backup timestamp is" $BACKUP_TIMESTAMP;
echo " Backup path is" $BACKUP_PATH;
echo " Number of daily backups to keep =" $NUMBER_OF_DAILY_BACKUPS_TO_KEEP;


#For each database currently in MySQL, take a database-level backup, then
list any backups older than a certain number of day
for ONE_DBNAME in `echo show databases | mysql -s -u $USERID -p$PASSWORD`
do
echo
echo "Backing up database" $ONE_DBNAME;
/usr/bin/mysqldump --opt --verbose -u${USERID} -p${PASSWORD}
${ONE_DBNAME} -r ${BACKUP_PATH}"/"${ONE_DBNAME}"."${BACKUP_TI
echo ">> Deleting these old backups for this database..."
/usr/bin/find ${BACKUP_PATH} -mtime
+$NUMBER_OF_DAILY_BACKUPS_TO_KEEP -name $ONE_DBNAME'*' -print; #display old
backups (i
/usr/bin/find ${BACKUP_PATH} -mtime
+$NUMBER_OF_DAILY_BACKUPS_TO_KEEP -name $ONE_DBNAME'*' -exec rm '{}' ';';
#delete old
done


echo
echo "** REPORT ENDS **";
---

If you want to take a backup manually with this script (and omit the email
being sent to you), you can do this from the mysql prompt via:
mysql> \. /home/rhino/MySQL/backup2.bash > /home/rhino/MySQL/backup2.out
2>&1


I think the biggest obstacle you're going to face in writing bash scripts is
the lack of good tutorials on it. There are umpteen bash references that
show you generic syntax and tell you the terminology used by bash but darned
few decent tutorials to show you how to write bash scripts. Some people can
do anything they want with only a reference but I'm one of those people who
need examples to really understand something so I've had real challenges
learning bash since the references are extremely skimpy on concrete
examples.


Good luck!

Rhino

----- Original Message -----
From: "HACKATHORN, TODD (SWBT)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 04, 2004 8:57 AM
Subject: Scripting


Hello,
I am new to Linux, and mySQL. I am currently a MsSQL Server 2000 and VB
programmer, but trying to break away from that side. I have my database
set
up and working great, but I am really struggling on how to perform
scheduled
updates, and data imports. Can anyone please point me to a good resource
to
learn how to build a script, that can import data from an ODBC connection,
and then maybe run multiple queries in the data one at a time. I don't
know
what language I want to use because I don't know enough about it. Once I
find a way to do what I need, I will learn that language. I think there
might be a way to use php as cron'd scripts, but I don't know. Also I
looked at perl, or just bash in linux. I am used to being able to do
anything I needed to with DTS packages and stored procedures. I had ask a
similar question a while back, and still can't get going with this. So
far
the graphical packages for updates are the only thing I miss from SQL
Server.

Thanks in advance for any help.

Todd Hackathorn



--


 |...........................................................|
 |____  _____ ____   _    |Victor Medina M                   |
 |\ \ \| ____|  _ \ / \   |Linux - Java - MySQL              |
 | \ \ \  _| | |_) / _ \  |Dpto. Sistemas - Ferreteria EPA   |
 | / / / |___|  __/ ___ \ |[EMAIL PROTECTED]                  |
 |/_/_/|_____|_| /_/   \_\|ext. 325 - Tél: +58-241-8507325   |
 |                        |geek by nature - linux by choice  |
 |...........................................................|






















--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to