ctlfd = open("/mnt/sql/ctl", OREAD|OWRITE);
write(fd, "your query");
read(fd, resultpath);
resultfd = open(resultpath, OREAD);
read(fd, result);
close(resultfd);
This is similar to the patterns used to open network connections or create new windows. /mnt/sql/myjoin:
echo "<sql query>" > /mnt/sql/myjoin
It's just representing writing and reading a database as file operations, they map pretty cleanly. Keep in mind that Plan 9 has per process views of the namespace so you don't have to worry about other processes messing up your /mnt/sql. rule:P check_query.rc: prereq rules
doaction
Where check_query may be a small shell script: #!/bin/rc
# redirect stdin/stdout to /mnt/sql/ctl
<> /mnt/sql/ctl {
# send the query to the DB
echo query
# print the response, check it for
# your condition.
cat `{sed 1q} | awk '$2 != "condition"{exit(1)}'
}
But I'm not familiar with an alternative using Make. You'd have to do something like: .PHONY: rule
rule: prereq rules
check_query.sh && doactionThat's exactly right, but notice that you are not actually using make at all any more at this point, except as a vehicle to run
check_query.sh && doaction
which is doing all work.
1. An email gets sent to a user
2. If there is no reply within a certain time frame, the email gets sent again
3. The above is repeated 3 times. If there is still no reply, a separate notification is sent to an admin account.
That is a common scenario, and trivial to implement as code. Show me how make would help here.
You have no DAG, and no actions that can be considered fresh/stale, so there's nothing for make to help with. SQL doesn't have much to do with that.
A file that represents the temporary table that has been created. Naming it is harder, unless the SQL query writer was feeling nice and verbose.
With that said, there are NoSQL databases these days whose query language is easily expressed as file paths. CouchDB, for example.
dbjoin.done: database.db
sqlite3 $< <<< "your query"
touch $@Say directories map to databases and files map to tables and views. You can create new tables and views by either writing data or an appropriate query. Views and result files would be read-only while data files would be writable. Writing to a data file would be done with a query which modifies the table and the result could be retrieved by then reading the file -- the modification time would be the time of the last update which is known.
Views and queries could be cached results from the last time they were ran which could be updated/rerun by touching them or they could be dynamic and update whenever a table they reference is updated.
How are you going to make the result of a join in a relational database into a file, symbolically or otherwise?