ctjacobs / pyqso

PyQSO is a contact logging tool for amateur radio operators.
http://christianjacobs.uk/pyqso
GNU General Public License v3.0
77 stars 19 forks source link

Log names can only container alphanumeric characters #77

Open ranguli opened 1 year ago

ranguli commented 1 year ago

Hello,

When I try to create a log group that contains any non-alphanumeric character (for example the log name special characters) I get the following error:

Traceback (most recent call last):
  File "/home/joshua/Downloads/pyqso-1.1.0/bin/../pyqso/logbook.py", line 151, in open
    self.summary.update()
  File "/home/joshua/Downloads/pyqso-1.1.0/bin/../pyqso/summary.py", line 232, in update
    self.items["QSO_COUNT"].set_label(str(self.logbook.record_count))
  File "/home/joshua/Downloads/pyqso-1.1.0/bin/../pyqso/logbook.py", line 1131, in record_count
    return sum([log.record_count for log in self.logs])
  File "/home/joshua/Downloads/pyqso-1.1.0/bin/../pyqso/logbook.py", line 1131, in <listcomp>
    return sum([log.record_count for log in self.logs])
  File "/home/joshua/Downloads/pyqso-1.1.0/bin/../pyqso/log.py", line 333, in record_count
    c.execute("SELECT Count(*) FROM %s" % self.name)
sqlite3.OperationalError: near "-": syntax error
ERROR:root:near "characters": syntax error
Traceback (most recent call last):
  File "/home/joshua/Downloads/pyqso-1.1.0/bin/../pyqso/logbook.py", line 279, in new_log
    c.execute(query)
sqlite3.OperationalError: near "characters": syntax error
ERROR:root:Database error. Try another log name.

I'm guessing this is because the log group name is passed verbatim into the SQL statement and that makes sqlite unhappy. Perhaps there is a way to get around this so that log names can contain spaces or other characters? Perhaps the log names can be stored in another table and accessed by some sort of identifier?