Skip to content

Commit 1c9ea2c

Browse files
committed
Completed assignment 6
1 parent 2dac472 commit 1c9ea2c

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Assignment6/learnSQL.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
# Adding another set of new field values-- sqlite3.OperationalError: near "t": syntax error
1515
cur.execute("""INSERT INTO FieldNotes (Day, Month, Year, Notes)
1616
VALUES (01, 10, 2013, 'Vegetation seems to have returned to normal for this time of year.
17-
The landscape isn't exactly green, but there is a decent amount of plant activity and there
17+
The landscape isn``t exactly green, but there is a decent amount of plant activity and there
1818
should be enough food for the rodents to the winter')""")
1919
con.commit()
2020

2121
#Update a mistaken value
2222
cur.execute("UPDATE FieldNotes SET Year = '2012' WHERE Day = 1 AND Month = 10 AND Year = 2013")
23-
con.commit()
23+
con.commit()
24+

Assignment6/portal_mammals

2 KB
Binary file not shown.

Assignment6/problem12.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import sqlite3 as dbapi
2+
3+
con = dbapi.connect("portal_mammals")
4+
cur = con.cursor()
5+
cur.execute("CREATE TABLE OldNewCodeKey(NewCode STR, OldCode STR)")
6+
7+
cur.execute("SELECT new_code, oldcode FROM PortalMammals_species")
8+
myqueryrecord = cur.fetchall()
9+
for newcode, oldcode in myqueryrecord:
10+
oldcodes = oldcode.split(",")
11+
for code in oldcodes:
12+
cur.execute("INSERT INTO OldNewCodeKey VALUES (?,?)", (newcode,code))
13+
con.commit()

0 commit comments

Comments
 (0)