Skip to content

Instantly share code, notes, and snippets.

@BitPuffin
Created December 9, 2013 22:23
Show Gist options
  • Save BitPuffin/7882082 to your computer and use it in GitHub Desktop.
Save BitPuffin/7882082 to your computer and use it in GitHub Desktop.
import db_sqlite
var db = Open(connection="foo.db", user="rumpf", password="fpmur", database="mydb")
proc getFromWhere*(id, row, table: string): TRow =
result = db.getRow(sql"select 1 from ? where ? = ?", table, row, id)
template getFrom*(id, table: string): expr =
getFromWhere(id, "id", table)
# foo! this line causes error
template getFoo(): expr =
"4".getFrom("users")
# bar!?
let v = getFoo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment