db

db#

local db = require 'db'

A collection of database utilities.

Functions#

db.printquery(db, sql[, cols])#

Print the results of a SQL query to the console.

Important

Since the sqlite class returns results as tables the order of columns will be arbitrary. The cols parameter can be specified to preserve column order.

Parameters:
  • db (sqlite) – A sqlite database to query.

  • sql (string) – A SQL query to execute.

  • cols (sequence) – A list of columns to display from the results.

Example#
-- run from the Lua Console
static = require 'gw2.static'
db = require 'db'

-- print the number of waypoints in Lion's Arch
db.printquery(static.db, "SELECT COUNT(*) FROM pois WHERE pois.map = 50 AND pois.type = 'waypoint'")
-- +----------+
-- | COUNT(*) |
-- +----------+
-- |       13 |
-- +----------+