commit 888aff86c55a14bc9365309056bdbf067af7a6c8 Author: Ary Borenszweig Date: Thu Mar 12 21:12:41 2015 -0300 Docs diff --git a/SQLite3.html b/SQLite3.html new file mode 100644 index 0000000..1253a05 --- /dev/null +++ b/SQLite3.html @@ -0,0 +1,43 @@ + + + + + + + + + +

module SQLite3

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SQLite3/Database.html b/SQLite3/Database.html new file mode 100644 index 0000000..eb8b5ce --- /dev/null +++ b/SQLite3/Database.html @@ -0,0 +1,520 @@ + + + + + + + + + +

class SQLite3::Database

+ + + +

Overview

+ +

The Database class encapsulates single connection to an SQLite3 database. Its usage is very straightforward:

+ +
require "sqlite3"
+
+db = SQLite3::Database.new( "data.db" )
+db.execute("select * from table") do |row|
+  p row
+end
+db.close
+ +

Lower level methods are also provided.

+ + + + + +

Superclass hierarchy

+
Object
Reference
SQLite3::Database
+ + + + + + + + + + + + +

Class Method Summary

+ + + + +

Instance Method Summary

+ + + + + + + +

Class Method Detail

+ +
+
+ + def self.new(filename, &block) +
+ +

Creates a new Database object that opens the given file, yields it, and closes it at the end.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def self.new(filename) +
+ +

Creates a new Database object that opens the given file.

+ + +
+
[View source]
+ +
+
+ + + + +

Instance Method Detail

+ +
+
+ + def close +
+ +

Closes this database.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def closed? +
+ +

Returns true if this database instance has been closed (see #close).

+ + +
+
[View source]
+ +
+
+ +
+
+ + def execute(sql, *binds, &block) +
+ +

Executes the given SQL statement. If additional parameters are given, they are treated as bind variables, +and are bound to the placeholders in the query.

+ +

Note that if any of the values passed to this are hashes, then the key/value pairs are each bound separately, +with the key being used as the name of the placeholder to bind the value to.

+ +

Yields one Array(Value) for each result.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def execute(sql, binds : Enumerable) +
+ +

Executes the given SQL statement. If additional parameters are given, they are treated as bind variables, +and are bound to the placeholders in the query.

+ +

Note that if any of the values passed to this are hashes, then the key/value pairs are each bound separately, +with the key being used as the name of the placeholder to bind the value to.

+ +

Returns an Array(Array(Value)).

+ + +
+
[View source]
+ +
+
+ +
+
+ + def execute(sql, *binds) +
+ +

Executes the given SQL statement. If additional parameters are given, they are treated as bind variables, +and are bound to the placeholders in the query.

+ +

Note that if any of the values passed to this are hashes, then the key/value pairs are each bound separately, +with the key being used as the name of the placeholder to bind the value to.

+ +

Returns an Array(Array(Value)).

+ + +
+
[View source]
+ +
+
+ +
+
+ + def execute(sql, binds : Enumerable, &block) +
+ +

Executes the given SQL statement. If additional parameters are given, they are treated as bind variables, +and are bound to the placeholders in the query.

+ +

Note that if any of the values passed to this are hashes, then the key/value pairs are each bound separately, +with the key being used as the name of the placeholder to bind the value to.

+ +

Yields one Array(Value) for each result.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def get_first_row(sql, binds : Enumerable) +
+ +

A convenience method that returns the first row of a query result.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def get_first_row(sql, *binds) +
+ +

A convenience method that returns the first row of a query result.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def get_first_value(sql, binds : Enumerable) +
+ +

A convenience method that returns the first value of the first row of a query result.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def get_first_value(sql, *binds) +
+ +

A convenience method that returns the first value of the first row of a query result.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def last_insert_row_id +
+ +

Obtains the unique row ID of the last row to be inserted by this Database instance. +This is an Int64.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def prepare(sql) +
+ +

Prepares an sql statement. Returns a Statement.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def query(sql, binds : Enumerable) +
+ +

Executes a query and gives back a ResultSet.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def query(sql, *binds) +
+ +

Executes a query and gives back a ResultSet.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def query(sql, *binds, &block) +
+ +

Executes a query and yields a ResultSet that will be closed at the end of the given block.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def query(sql, binds : Enumerable, &block) +
+ +

Executes a query and yields a ResultSet that will be closed at the end of the given block.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def quote(string) +
+ +

Quotes the given string, making it safe to use in an SQL statement. +It replaces all instances of the single-quote character with two single-quote characters.

+ + +
+
[View source]
+ +
+
+ + + + + + + + diff --git a/SQLite3/Exception.html b/SQLite3/Exception.html new file mode 100644 index 0000000..f712f53 --- /dev/null +++ b/SQLite3/Exception.html @@ -0,0 +1,106 @@ + + + + + + + + + +

class SQLite3::Exception

+ + + +

Overview

+ +

Exception thrown on invalid SQLite3 operations.

+ + + + + +

Superclass hierarchy

+
Object
Reference
Exception
SQLite3::Exception
+ + + + + + + + + + + + +

Class Method Summary

+ + + + +

Instance Method Summary

+ + + + + + + +

Class Method Detail

+ +
+
+ + def self.new(db) +
+ + +
+
[View source]
+ +
+
+ + + + +

Instance Method Detail

+ +
+
+ + def code +
+ +

The internal code associated with the failure.

+ + +
+
[View source]
+ +
+
+ + + + + + + + diff --git a/SQLite3/ResultSet.html b/SQLite3/ResultSet.html new file mode 100644 index 0000000..3f37b5f --- /dev/null +++ b/SQLite3/ResultSet.html @@ -0,0 +1,250 @@ + + + + + + + + + +

class SQLite3::ResultSet

+ + + +

Overview

+ +

The ResultSet object encapsulates the enumerability of a query’s output. +It is a simple cursor over the data that the query returns.

+ +

Typical usage is:

+ +
require "sqlite3"
+
+db = SQLite3::Database.new("foo.db")
+stmt = db.prepare("select * from person")
+result_set = stmt.execute
+while result_set.next
+  p result_set.to_a
+end
+stmt.close
+db.close
+ + + + + +

Superclass hierarchy

+
Object
Reference
SQLite3::ResultSet
+ + + + + + + + + + + + + + +

Instance Method Summary

+ + + + + + + + + +

Instance Method Detail

+ +
+
+ + def [](index_or_name) +
+ +

Returns the value of a column by index or name.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def close +
+ +

Closes this result set, closing the associated statement.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def closed? +
+ +

Returns true if the associated statement is closed.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def column_count +
+ +

Returns the number of columns.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def columns +
+ +

Returns the names of the columns, an Array(String).

+ + +
+
[View source]
+ +
+
+ +
+
+ + def next +
+ +

Advances to the next row. Returns true if there's a next row, +false otherwise. Must be called at least once to advance to the first +row.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def to_a +
+ +

Return the current row's value as an Array(Value).

+ + +
+
[View source]
+ +
+
+ +
+
+ + def types +
+ +

Returns the types of the columns, an Array(Type).

+ + +
+
[View source]
+ +
+
+ + + + + + + + diff --git a/SQLite3/Statement.html b/SQLite3/Statement.html new file mode 100644 index 0000000..5d9c874 --- /dev/null +++ b/SQLite3/Statement.html @@ -0,0 +1,568 @@ + + + + + + + + + +

class SQLite3::Statement

+ + + +

Overview

+ +

A statement represents a prepared-but-unexecuted SQL query.

+ + + + + +

Superclass hierarchy

+
Object
Reference
SQLite3::Statement
+ + + + + + + + + + + + + + +

Instance Method Summary

+ + + + + + + + + +

Instance Method Detail

+ +
+
+ + def [](index : Int) +
+ +

Returns the value of the given column by index (1-based).

+ + +
+
[View source]
+ +
+
+ +
+
+ + def [](name : String) +
+ +

Returns the value of the given column by name.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def []=(index : Int, value : Int64) +
+ +

Binds the parameter at the given index to an Int64.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def []=(index : Int, value : Int32) +
+ +

Binds the parameter at the given index to an Int32.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def []=(index : Int, value : Nil) +
+ +

Binds the parameter at the given index to an Int.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def []=(name : String | Symbol, value) +
+ +

Binds a named parameter, using the :AAAA naming scheme for parameters.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def []=(index : Int, hash : Hash) +
+ +

Binds a hash to this statement (the index is ignored).

+ + +
+
[View source]
+ +
+
+ +
+
+ + def []=(index : Int, value : Slice(UInt8)) +
+ +

Binds the parameter at the given index to a BLOB.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def []=(index : Int, value : Float) +
+ +

Binds the parameter at the given index to a Float.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def []=(index : Int, value : String) +
+ +

Binds the parameter at the given index to a String.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def close +
+ +

Closes this statement.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def closed? +
+ +

Returns true if this statement is closed. See #close.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def column_count +
+ +

Returns the number of columns in this statement.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def column_name(index) +
+ +

Returns the name of the column at the given index.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def column_type(index : Int) +
+ +

Returns the Type of the column at the given index.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def columns +
+ +

Returns the column names of this statement.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def execute(*binds, &block) +
+ +

Executes this statement with the given binds and yields a ResultSet that +will be closed at the end of the block.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def execute(binds : Enumerable | Slice(UInt8), &block) +
+ +

Executes this statement with the given binds and yields a ResultSet that +will be closed at the end of the block.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def execute(binds : Slice(UInt8)) +
+ +

Executes this statement with a single BLOB bind and returns a ResultSet.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def execute(binds : Enumerable) +
+ +

Executes this statement with the given binds and returns a ResultSet.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def execute(*binds) +
+ +

Executes this statement with the given binds and returns a ResultSet.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def reset +
+ +

Reset this statment, allowing to re-execute it with new binds.

+ + +
+
[View source]
+ +
+
+ +
+
+ + def types +
+ +

Returns an Array(Type) of this statement's columns. Note that the statement +must be executed in order for this to return sensible values, otherwise all types +will be NULL.

+ + +
+
[View source]
+ +
+
+ + + + + + + + diff --git a/SQLite3/Type.html b/SQLite3/Type.html new file mode 100644 index 0000000..558ce89 --- /dev/null +++ b/SQLite3/Type.html @@ -0,0 +1,75 @@ + + + + + + + + + +

enum SQLite3::Type

+ + + + + + + + + + + + + + + + + +

Enum Members

+ + + + + + + + + + + + + + + + + + + + diff --git a/SQLite3/Value.html b/SQLite3/Value.html new file mode 100644 index 0000000..e314206 --- /dev/null +++ b/SQLite3/Value.html @@ -0,0 +1,50 @@ + + + + + + + + + +

alias SQLite3::Value

+ + + +

Overview

+ +

All possible values of each column of a row returned by Database#execute.

+ + + +

Alias Definition

+ Nil | Int64 | Float64 | String | Slice(UInt8) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/css/style.css b/css/style.css new file mode 100644 index 0000000..9d56f01 --- /dev/null +++ b/css/style.css @@ -0,0 +1,92 @@ +body { + font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif; +} + +.entry-summary { + padding-bottom: 4px; +} + +.entry-summary .signature { + padding: 4px 8px; + margin-bottom: 4px; + display: inline-block; + background: #f8f8f8; + color: #05a; + border: 1px solid #f0f0f0; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; +} + +.entry-summary .signature:hover { + background: #CFEBFF; + border-color: #A4CCDA; +} + +.entry-summary .summary { + padding-left: 32px; +} + +.entry-summary a { + text-decoration: none; +} + +.entry-detail .signature { + padding: 6px 10px; + margin-bottom: 10px; + display: inline-block; + background: #E8F4FF; + border: 1px solid #d8d8e5 + border-radius: 5px; +} + +hr { + color: #ddd; + background-color: #ddd; + height: 1px; + border: 0; + margin-top: 20px; + margin-bottom: 10px; +} + +pre { + padding: 10px 20px; + margin-top: 4px; + border-radius: 3px; + line-height: 1.45; + overflow: auto; + color: #333; + background: #f7f7f7; + font-size: 14px; +} + +.c { + color: #969896; +} + +.n { + color: #0086b3; +} + +.t { + color: #0086b3; +} + +.s { + color: #183691; +} + +.i { + color: #7f5030; +} + +.k { + color: #a71d5d; +} + +.o { + color: #a71d5d; +} + +.m { + color: #795da3; +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..078aae2 --- /dev/null +++ b/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/list.html b/list.html new file mode 100644 index 0000000..c8deea2 --- /dev/null +++ b/list.html @@ -0,0 +1,53 @@ + + + + + + + + + + + diff --git a/main.html b/main.html new file mode 100644 index 0000000..08b64e5 --- /dev/null +++ b/main.html @@ -0,0 +1,32 @@ + + + + + + + +

crystal-sqlite3

+ +

SQLite3 bindings for Crystal.

+ +

This is a work in progress.

+ +

Documentation

+ +

Projectfile

+ +
deps do
+  github "manastech/crystal-sqlite3"
+end
+ +

Usage

+ +
require "sqlite3"
+
+db = SQLite3::Database.new( "data.db" )
+db.execute("select * from table") do |row|
+  p row
+end
+db.close
+ +