Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: bc75d8a4b1
Fetching contributors…

Cannot retrieve contributors at this time

file 31 lines (25 sloc) 0.643 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
package sqlite3

import "C"

import "fmt"
import "os"

type Table struct {
Name string
ColumnSpec string
}

func (t *Table) Create(db *Database) (e os.Error) {
sql := fmt.Sprintf("CREATE TABLE %v (%v);", t.Name, t.ColumnSpec)
_, e = db.Execute(sql)
return
}

func (t *Table) Drop(db *Database) (e os.Error) {
sql := fmt.Sprintf("DROP TABLE IF EXISTS %v;", t.Name, t.ColumnSpec)
_, e = db.Execute(sql)
return
}

func (t *Table) Rows(db *Database) (c int, e os.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
}
Something went wrong with that request. Please try again.