This specific content was written 12 years ago.
Please keep this in mind as it may be outdated and not adhering to best-practices.
Below we see an example of calling a mysql script from a file and passing a param.
sql script
So make a file with the following (or whatever else you wish):
SET @i = 1;
use databaseName;
SET @pID=@i+100;
SET @partnerID=concat('partner',@pID);
select @i, @pID , @partnerID;
Now, this will print out the values of i, pID, and partnerID.
Below that you could include insert statements or whatever else you wish.
Now how do we call this from bash and set the @i param?
bash script
user=root
password=mysqlPass
database=db
for i in {300..400..5}
do
sed -i "1 s/.*/set @i=$i;/" sample.sql
mysql --user="$user" --password="$password" < sample.sql
done
So how does this work?
We use sed to replace the first line completely in sample.sql with a new “set @i=” command containing the i param we want.
We then call mysql and feed the rewritten file.
Another way to do this would be to concatenate the sample.sql contents to the set command, and feed them to mysql in memory.
Sep 15 2015
Git: How to merge your branch
1. Merging on develop
This method is the most frequently used. It uses the recursive automatic merging method of Git to merge the changes of your branch upon the main develop branch.
2. Merging with rebase
In this method you are applying the develop branch upon yourBranch. If there is a conflict in the process of merging the process stops and you must fix your conflicts manually which may be an advantage some developers. Moreover it does not produce a merge commit message, so it helps to keep the commit history clean.
3. Merging with pull on your branch
By Giannis Kanellopoulos • GIT, GIT version control, Uncategorized 0