Skip to content

Commit

Permalink
Use bind params for insert into stations so names with apostrophes work.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Aug 16, 2014
1 parent f435846 commit 9dc9b98
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion import.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
rejectUnknown = False

tdb = TradeDB(r'.\TradeDangerous.accdb')
sqlEscapeRe = re.compile(r'([\\\'\"%;])')

categories = dict()
for row in tdb.fetch_all("""
Expand Down Expand Up @@ -84,7 +85,7 @@ def changeStation(line):
try:
station = tdb.getStation(stnName)
except LookupError:
tdb.query("INSERT INTO Stations (system, station) VALUES ('%s', '%s')" % (sysName, stnName)).commit()
tdb.query("INSERT INTO Stations (system, station) VALUES (?, ?)", [sysName, stnName]).commit()
print("Added %s/%s" % (sysName, stnName))
tdb.load()
station = tdb.getStation(stnName)
Expand Down

0 comments on commit 9dc9b98

Please sign in to comment.