From 7cc79e3d99870464d6f50204e84c27655b1484a0 Mon Sep 17 00:00:00 2001 From: Greg Wilson Date: Sat, 21 Dec 2013 07:40:27 -0500 Subject: [PATCH] Switching to triple-tilde in Markdown code blocks in IPython Notebooks W. Trevor King: I removed everything except the sql/novice changes from the original c6e5b9c [1]. [1]: https://github.com/swcarpentry/bc/commit/c6e5b9cb15e259680e413f289d9bb96c538e7ffd --- sql/novice/01-select.ipynb | 8 ++--- sql/novice/03-filter.ipynb | 4 +-- sql/novice/05-null.ipynb | 4 +-- sql/novice/06-agg.ipynb | 8 ++--- sql/novice/07-join.ipynb | 4 +-- sql/novice/08-create.ipynb | 64 ++++++++++++++++++++++---------------- sql/novice/09-prog.ipynb | 8 +++-- 7 files changed, 58 insertions(+), 42 deletions(-) diff --git a/sql/novice/01-select.ipynb b/sql/novice/01-select.ipynb index 42f461b..4455598 100644 --- a/sql/novice/01-select.ipynb +++ b/sql/novice/01-select.ipynb @@ -394,15 +394,15 @@ "\n", "2. Many people format queries as:\n", "\n", - " ```\n", + " ~~~\n", " SELECT personal, family FROM person;\n", - " ```\n", + " ~~~\n", "\n", " or as:\n", "\n", - " ```\n", + " ~~~\n", " select Personal, Family from PERSON;\n", - " ```\n", + " ~~~\n", "\n", " What style do you find easiest to read, and why?" ] diff --git a/sql/novice/03-filter.ipynb b/sql/novice/03-filter.ipynb index 0182954..c9a3e95 100644 --- a/sql/novice/03-filter.ipynb +++ b/sql/novice/03-filter.ipynb @@ -422,9 +422,9 @@ "1. Suppose we want to select all sites that lie within 30° of the equator.\n", " Our first query is:\n", "\n", - " ```\n", + " ~~~\n", " select * from Site where (lat > -30) or (lat < 30);\n", - " ```\n", + " ~~~\n", "\n", " Explain why this is wrong,\n", " and rewrite the query so that it is correct.\n", diff --git a/sql/novice/05-null.ipynb b/sql/novice/05-null.ipynb index 8b02654..5173fb3 100644 --- a/sql/novice/05-null.ipynb +++ b/sql/novice/05-null.ipynb @@ -400,9 +400,9 @@ "\n", "1. What do you expect the query:\n", "\n", - " ```\n", + " ~~~\n", " select * from Visited where dated in ('1927-02-08', null);\n", - " ```\n", + " ~~~\n", "\n", " to produce?\n", " What does it actually produce?\n", diff --git a/sql/novice/06-agg.ipynb b/sql/novice/06-agg.ipynb index 635a7f6..4982a97 100644 --- a/sql/novice/06-agg.ipynb +++ b/sql/novice/06-agg.ipynb @@ -687,9 +687,9 @@ " and the average of all the radiation readings.\n", " We write the query:\n", "\n", - " ```\n", + " ~~~\n", " select reading-avg(reading) from Survey where quant='rad';\n", - " ```\n", + " ~~~\n", "\n", " What does this actually produce, and why?\n", "\n", @@ -700,9 +700,9 @@ " Use this to produce a one-line list of scientists' names,\n", " such as:\n", "\n", - " ```\n", + " ~~~\n", " William Dyer, Frank Pabodie, Anderson Lake, Valentina Roerich, Frank Danforth\n", - " ```\n", + " ~~~\n", "\n", " Can you find a way to order the list by surname?" ] diff --git a/sql/novice/07-join.ipynb b/sql/novice/07-join.ipynb index 2481db4..a5afa8f 100644 --- a/sql/novice/07-join.ipynb +++ b/sql/novice/07-join.ipynb @@ -414,10 +414,10 @@ "\n", "3. Describe in your own words what the following query produces:\n", "\n", - " ```\n", + " ~~~\n", " select Site.name from Site join Visited\n", " on Site.lat<-49.0 and Site.name=Visited.site and Visited.dated>='1932-00-00';\n", - " ```" + " ~~~" ] } ], diff --git a/sql/novice/08-create.ipynb b/sql/novice/08-create.ipynb index b3e9c3e..c695563 100644 --- a/sql/novice/08-create.ipynb +++ b/sql/novice/08-create.ipynb @@ -34,14 +34,18 @@ "For example,\n", "the following statements create the four tables in our survey database:\n", "\n", - " create table Person(ident text, personal text, family text);\n", - " create table Site(name text, lat real, long real);\n", - " create table Visited(ident integer, site text, dated text);\n", - " create table Survey(taken integer, person text, quant real, reading real);\n", + "~~~\n", + "create table Person(ident text, personal text, family text);\n", + "create table Site(name text, lat real, long real);\n", + "create table Visited(ident integer, site text, dated text);\n", + "create table Survey(taken integer, person text, quant real, reading real);\n", + "~~~\n", "\n", "We can get rid of one of our tables using:\n", - " \n", - " drop table Survey;\n", + "\n", + "~~~\n", + "drop table Survey;\n", + "~~~\n", "\n", "Be very careful when doing this:\n", "most databases have some support for undoing changes,\n", @@ -70,16 +74,18 @@ "we can specify several kinds of constraints on its columns.\n", "For example,\n", "a better definition for the `Survey` table would be:\n", - " \n", - " create table Survey(\n", - " taken integer not null, -- where reading taken\n", - " person text, -- may not know who took it\n", - " quant real not null, -- the quantity measured\n", - " reading real not null, -- the actual reading\n", - " primary key(taken, quant),\n", - " foreign key(taken) references Visited(ident),\n", - " foreign key(person) references Person(ident)\n", - " );\n", + "\n", + "~~~\n", + "create table Survey(\n", + " taken integer not null, -- where reading taken\n", + " person text, -- may not know who took it\n", + " quant real not null, -- the quantity measured\n", + " reading real not null, -- the actual reading\n", + " primary key(taken, quant),\n", + " foreign key(taken) references Visited(ident),\n", + " foreign key(person) references Person(ident)\n", + ");\n", + "~~~\n", "\n", "Once again,\n", "exactly what constraints are avialable\n", @@ -91,14 +97,18 @@ "`insert` and `delete`.\n", "The simplest form of `insert` statement lists values in order:\n", "\n", - " insert into Site values('DR-1', -49.85, -128.57);\n", - " insert into Site values('DR-3', -47.15, -126.72);\n", - " insert into Site values('MSK-4', -48.87, -123.40);\n", + "~~~\n", + "insert into Site values('DR-1', -49.85, -128.57);\n", + "insert into Site values('DR-3', -47.15, -126.72);\n", + "insert into Site values('MSK-4', -48.87, -123.40);\n", + "~~~\n", "\n", "We can also insert values into one table directly from another:\n", - " \n", - " create table JustLatLong(lat text, long TEXT);\n", - " insert into JustLatLong select lat, long from site;\n", + "\n", + "~~~\n", + "create table JustLatLong(lat text, long TEXT);\n", + "insert into JustLatLong select lat, long from site;\n", + "~~~\n", "\n", "Deleting records can be a bit trickier,\n", "because we have to ensure that the database remains internally consistent.\n", @@ -108,8 +118,10 @@ "For example,\n", "once we realize that Frank Danforth didn't take any measurements,\n", "we can remove him from the `Person` table like this:\n", - " \n", - " delete from Person where ident = \"danforth\";\n", + "\n", + "~~~\n", + "delete from Person where ident = \"danforth\";\n", + "~~~\n", "\n", "But what if we removed Anderson Lake instead?\n", "Our `Survey` table would still contain seven records\n", @@ -157,11 +169,11 @@ " containing temperature readings by Robert Olmstead,\n", " which is formatted like this:\n", "\n", - " ```\n", + " ~~~\n", " Taken,Temp\n", " 619,-21.5\n", " 622,-15.5\n", - " ```\n", + " ~~~\n", "\n", " Write a small Python program that reads this file in\n", " and prints out the SQL `insert` statements needed\n", diff --git a/sql/novice/09-prog.ipynb b/sql/novice/09-prog.ipynb index e743ffb..6105f8c 100644 --- a/sql/novice/09-prog.ipynb +++ b/sql/novice/09-prog.ipynb @@ -156,14 +156,18 @@ "This seems simple enough,\n", "but what happens if someone gives us this string as input?\n", "\n", - " dyer'; drop table Survey; select '\n", + "~~~\n", + "dyer'; drop table Survey; select '\n", + "~~~\n", "\n", "It looks like there's garbage after the name of the project,\n", "but it is very carefully chosen garbage.\n", "If we insert this string into our query,\n", "the result is:\n", "\n", - " select personal || ' ' || family from Person where ident='dyer'; drop tale Survey; select '';\n", + "~~~\n", + "select personal || ' ' || family from Person where ident='dyer'; drop tale Survey; select '';\n", + "~~~\n", "\n", "If we execute this,\n", "it will erase one of the tables in our database.\n", -- 2.26.2