This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Query in MySql: | |
| 2001: | |
| mysql> select avg(bike_2001), max(bike_2001), min(bike_2001) from cycling; | |
| +----------------+----------------+----------------+ | |
| | avg(bike_2001) | max(bike_2001) | min(bike_2001) | | |
| +----------------+----------------+----------------+ | |
| | 2448.4000 | 4929 | 1351 | | |
| +----------------+----------------+----------------+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Query in MySql: | |
| mysql> select borough, percentage_2001, percentage_2011 from cycling group by borough; | |
| +---------------+-----------------+-----------------+ | |
| | borough | percentage_2001 | percentage_2011 | | |
| +---------------+-----------------+-----------------+ | |
| | Croydon | 1.0 | 1.3 | | |
| | Greenwich | 1.5 | 2.3 | | |
| | Hackney | 6.2 | 9.9 | | |
| | Lewisham | 1.8 | 4.0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Query in MySql: | |
| mysql> select SUM(work_2001), SUM(Bike_2001), SUM(Work_2011), SUM(Bike_2011) from cycling; | |
| +----------------+----------------+----------------+----------------+ | |
| | SUM(work_2001) | SUM(Bike_2001) | SUM(Work_2011) | SUM(Bike_2011) | | |
| +----------------+----------------+----------------+----------------+ | |
| | 516155 | 12242 | 666294 | 35709 | | |
| +----------------+----------------+----------------+----------------+ | |
| 1 row in set (0.00 sec) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Query in MySql: | |
| mysql> select area, count(*) as count from bike where borough = 'Lewisham' group by area; | |
| +---------------------------------+-------+ | |
| | area | count | | |
| +---------------------------------+-------+ | |
| | Lewisham (underground) | 6 | | |
| | On or near Bus/coach Station | 2 | | |
| | On or near Catford Broadway | 1 | | |
| | On or near Lewis Grove | 3 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Query in MySql: | |
| mysql> select borough, investigation, count(*) from bike where borough = 'Lewisham' group by investigation; | |
| +----------+-----------------------------------+----------+ | |
| | borough | investigation | count(*) | | |
| +----------+-----------------------------------+----------+ | |
| | Lewisham | No further action at this time | 10 | | |
| | Lewisham | Offender given community sentence | 1 | | |
| | Lewisham | Under investigation | 13 | | |
| +----------+-----------------------------------+----------+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Query in MySql: | |
| mysql> select borough, date, count(*) as count from bike where borough = 'Lewisham' group by date; | |
| +----------+------------+-------+ | |
| | borough | date | count | | |
| +----------+------------+-------+ | |
| | Lewisham | 2013-05-01 | 4 | | |
| | Lewisham | 2013-06-01 | 1 | | |
| | Lewisham | 2013-07-01 | 2 | | |
| | Lewisham | 2013-08-01 | 6 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Query in MySql: | |
| mysql> select borough, date, count(*) from bike where borough = 'Lewisham' group by date; | |
| +----------+------------+----------+ | |
| | borough | date | count(*) | | |
| +----------+------------+----------+ | |
| | Lewisham | 2013-05-01 | 4 | | |
| | Lewisham | 2013-06-01 | 1 | | |
| | Lewisham | 2013-07-01 | 2 | | |
| | Lewisham | 2013-08-01 | 6 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mysql> select date, count(*) as count from bike group by date; | |
| +------------+-------+ | |
| | date | count | | |
| +------------+-------+ | |
| | 2013-05-01 | 45 | | |
| | 2013-06-01 | 68 | | |
| | 2013-07-01 | 53 | | |
| | 2013-08-01 | 40 | | |
| | 2013-09-01 | 54 | | |
| | 2013-10-01 | 61 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mysql> LOAD DATA LOCAL INFILE "cycling.csv" INTO TABLE cycling FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r' IGNORE 1 LINES; | |
| Query OK, 5 rows affected, 1 warning (0.00 sec) | |
| Records: 5 Deleted: 0 Skipped: 0 Warnings: 1 | |
| mysql> select * from cycling; | |
| +---------------+-----------+-----------+-----------------+-----------+-----------+-----------------+-------------------+ | |
| | Borough | Work_2001 | Bike_2001 | Percentage_2001 | Work_2011 | Bike_2011 | Percentage_2011 | Percentage_change | | |
| +---------------+-----------+-----------+-----------------+-----------+-----------+-----------------+-------------------+ | |
| | Croydon | 156838 | 1636 | 1.0 | 172987 | 2172 | 1.3 | 0.3 | | |
| | Greenwich | 91575 | 1351 | 1.5 | 117821 | 2738 | 2.3 | 0.8 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Creating table in Python | |
| import pymysql, sys | |
| try: | |
| conn = pymysql.connect(host='localhost', | |
| port=3306, | |
| user='co302mc', | |
| passwd='mafol597', | |
| db='co302mc_bike_theft') |