From 5847a9c7e987f329d9b17d36d06eafabfc87d309 Mon Sep 17 00:00:00 2001 From: Markus Pieton Date: Wed, 1 Feb 2012 19:02:14 +0100 Subject: [PATCH] Table documentation added. --- table.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/table.go b/table.go index b792fd9..91126b4 100644 --- a/table.go +++ b/table.go @@ -3,27 +3,31 @@ package sqlite3 import "C" import "fmt" +// Table implements a high level view of a SQL table. type Table struct { Name string ColumnSpec string } +// Create is used to create a SQL table. func (t *Table) Create(db *Database) (e error) { sql := fmt.Sprintf("CREATE TABLE %v (%v);", t.Name, t.ColumnSpec) _, e = db.Execute(sql) return } +// Drop is used to delete a SQL table. func (t *Table) Drop(db *Database) (e error) { sql := fmt.Sprintf("DROP TABLE IF EXISTS %v;", t.Name, t.ColumnSpec) _, e = db.Execute(sql) return } +// Rows returns the number of rows in the table. func (t *Table) Rows(db *Database) (c int, e error) { sql := fmt.Sprintf("SELECT Count(*) FROM %v;", t.Name) _, e = db.Execute(sql, func(s *Statement, values ...interface{}) { c = int(values[0].(int64)) }) return -} \ No newline at end of file +}