Esempio n. 1
0
func main() {
	// Define the connexion parameters
	//driver := "postgres"
	//uri := "postgres://*****:*****@localhost:5433/taxisid?sslmode=disable"

	driver := "mysql"
	uri := "root@tcp(localhost:3306)/privateaser_dev"

	// Initialize the database connexion and the associated sniffer
	sniffer, db, err := marlowe.Initialize(driver, uri)
	if err != nil {
		fmt.Println(err)
	}
	defer db.Close()

	// Initialize a metadata container
	var metadata marlowe.Metadata

	// Sniff the metadata
	err = marlowe.SniffTables(sniffer, db, &metadata)
	if err != nil {
		fmt.Println(err)
	}

	// Display the tables
	for i, table := range metadata.Tables {
		fmt.Println(i, "-", table.Name)
	}
}
Esempio n. 2
0
func sniff(w http.ResponseWriter, r *http.Request) {
	// Parse the form
	r.ParseForm()
	driver := r.FormValue("driver")
	uri := r.FormValue("uri")

	// Initialize the database connexion and the associated sniffer
	sniffer, db, err := marlowe.Initialize(driver, uri)
	if err != nil {
		fmt.Println(err)
	}
	defer db.Close()

	// Initialize a metadata container
	var metadata marlowe.Metadata

	// Sniff the metadata
	err = marlowe.SniffTables(sniffer, db, &metadata)
	err = marlowe.SniffAttributes(sniffer, db, &metadata)
	err = marlowe.SniffConstraints(sniffer, db, &metadata)

	// Display the metadata
	t, _ := template.ParseFiles("static/metadata.html")
	t.Execute(w, metadata)
}