Beispiel #1
0
func main() {

	//var ast []*dbdb.QueryStmt

	query := "QUERY users WHERE id ^ `0`, email = `[email protected]`, name = `Scott Cagno`"
	parser := dbdb.NewParser(strings.NewReader(query))
	stmt, err := parser.Parse()
	if err != nil && err != io.EOF {
		log.Fatal(err)
	}
	fmt.Printf("%v\n", stmt)

	/*
		fmt.Println("Sample select statements...")
		for _, query := range queries {
			fmt.Println(query)
		}

		for _, query := range queries {
			parser := dbdb.NewParser(strings.NewReader(query))
			stmt, err := parser.Parse()
			if err != nil && err != io.EOF {
				log.Fatal(err)
			}
			ast = append(ast, stmt)
		}

		for _, stmt := range ast {
			fmt.Printf("%+#v\n", stmt)
		}
	*/
}
Beispiel #2
0
func (d *Data) Query(query string) []interface{} {
	parser := dbdb.NewParser(strings.NewReader(query))
	stmt, err := parser.Parse()
	if err != nil && err != io.EOF {
		log.Fatal(err)
	}
	if d.name != stmt.Store {
		return nil
	}
	fmt.Println(stmt.Store)
	//var results []interface{}
	for _, set := range stmt.Set {
		fmt.Printf("%+v\n", set)
	}
	return nil
}