| 21 | } |
| 22 | |
| 23 | func (m *githubModule) Create(c *sqlite3.SQLiteConn, args []string) (sqlite3.VTab, error) { |
| 24 | // args holds the raw xCreate arguments: args[0] is the module name, |
| 25 | // args[1] the database name, args[2] the virtual table name, and any |
| 26 | // user arguments follow. |
| 27 | if len(args) < 3 { |
| 28 | return nil, fmt.Errorf("githubModule: unexpected arguments: %v", args) |
| 29 | } |
| 30 | tableName := `"` + strings.ReplaceAll(args[2], `"`, `""`) + `"` |
| 31 | err := c.DeclareVTab(fmt.Sprintf(` |
| 32 | CREATE TABLE %s ( |
| 33 | id INT, |
| 34 | full_name TEXT, |
| 35 | description TEXT, |
| 36 | html_url TEXT |
| 37 | )`, tableName)) |
| 38 | if err != nil { |
| 39 | return nil, err |
| 40 | } |
| 41 | return &ghRepoTable{}, nil |
| 42 | } |
| 43 | |
| 44 | func (m *githubModule) Connect(c *sqlite3.SQLiteConn, args []string) (sqlite3.VTab, error) { |
| 45 | return m.Create(c, args) |