class GetSQL
- GetSQL
- Reference
- Object
Overview
GetSQL provides functions for extracting meta-information from a databases in a generic fashion, and for making requests.
Included Modules
- HTTP::Handler
Defined in:
getsql.crConstant Summary
-
COLUMNS =
{"sqlite3" => "SELECT name FROM pragma_table_info('%s')", "postgres" => "SELECT column_name FROM information_schema.columns WHERE table_name = '%s'"}
-
INDICES =
{"sqlite3" => "SELECT sql FROM sqlite_schema WHERE type = 'index' AND tbl_name = '%s'", "postgres" => "SELECT indexdef FROM pg_indexes WHERE schemaname = 'public' AND tablename = '%s'"}
-
Each entry is a query to return 2-column rows, with the name of a table and the definition of an index.
-
JSON =
MIME.from_extension(".json")
-
The default content type
-
TABLES =
{"sqlite3" => "SELECT tbl_name FROM sqlite_schema WHERE type = 'table'", "postgres" => "SELECT table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema = 'public'"}
-
Each entry is a query to return single column rows with the names of all tables in a database.
Constructors
Class Method Summary
- .column_type(uri : URI, table : String, column : String)
- .columns(uri : URI, table : String)
- .indices(uri : URI, table : String)
-
.ok?(uri : URI)
True if and only if the database at the URI can be reached.
- .query(uri : URI, table : String, params : Enumerable(Tuple(String, String)) | Nil = nil, limit : Int = 1, offset : Int = 0)
-
.redacted(uri : URI | String) : URI
Gets a redacted version of the URI (with the password obfuscated).
- .tables(uri : URI)
- .where(params : Enumerable(Tuple(String, String)) | Nil)
Instance Method Summary
-
#add(name : String, uri : URI)
Adds a new connection with the given name.
-
#add(name : String, uri : String)
Adds a new connection with the given name.
-
#add(uri : URI)
Adds a new connection named by the first element in the URI's path (excluding any file extension)
-
#add(uri : String)
Adds a new connection named by the first element in the URI's path (excluding any file extension)
- #call(context)
- #database(name)
- #databases
-
#indices(db : String, table : String)
Gets the indices in the database, as a map of index definitions per table.
-
#ok?(name : String)
True if and only if the database at the URI corresponding to the given name can be reached.
- #query(db : String, table : String, params : Enumerable(Tuple(String, String)) | Nil = nil, limit : Int = 1, offset : Int = 0)
-
#remove(name : String)
Removes the named connection, if it exists.
- #respond(context, &)
-
#tables(db : String)
Gets the tables in the database specified by
uri
. - #version
Constructor Detail
Class Method Detail
Gets a redacted version of the URI (with the password obfuscated).
Instance Method Detail
Adds a new connection named by the first element in the URI's path (excluding any file extension)
Adds a new connection named by the first element in the URI's path (excluding any file extension)
Gets the indices in the database, as a map of index definitions per table.
True if and only if the database at the URI corresponding to the given name can be reached.