tiny_sqlite icon indicating copy to clipboard operation
tiny_sqlite copied to clipboard

Feature: a `proc exec()` without auto-convert toDbValue

Open Moaneschien opened this issue 3 years ago • 0 comments

Feature request: a proc exec() that does not auto-convert toDbValue Sometimes it can be handy to do the toDbValue conversion by hand.

dbWriteStatement is of type Table[string, SqlStatement]

if dbWriteStatement.hasKey(topic):
  if datatype[topic] == "float":
    let data = parseFloat(payload).float64
    dbWriteStatement[topic].exec(topic, data)
  elif datatype[topic] == "integer":
    let data = parseInt(payload).int64
    dbWriteStatement[topic].exec(topic, data)
  elif datatype[topic] == "string":
    let data = payload 
    dbWriteStatement[topic].exec(topic, data)

versus:

if dbWriteStatement.hasKey(topic):
  if datatype[topic] == "float":
    let data = toDbValue(parseFloat(payload).float64)
  elif datatype[topic] == "integer":
    let data = toDbValue(parseInt(payload).int64)
  elif datatype[topic] == "string":
    let data = toDbValue(payload )
  dbWriteStatement[topic].exec(topic, data)

Moaneschien avatar Oct 17 '22 17:10 Moaneschien