فهرست منبع

удален дубликант connector.go

toomanysugar 3 سال پیش
والد
کامیت
ed099c9cf9
1فایلهای تغییر یافته به همراه0 افزوده شده و 85 حذف شده
  1. 0 85
      dbconnector.go

+ 0 - 85
dbconnector.go

@@ -1,85 +0,0 @@
-
-package main
-
-import (
-	"fmt"
-	"io/ioutil"
-	"encoding/json"
-	"database/sql"
-	_ "github.com/go-sql-driver/mysql"
-)
-
-type ConnectionProperties struct {
-	User 	string
-	Pass 	string
-	Host	string
-	Db 		string
-}
-
-type connection struct {
-	dBOpenStr string
-}
-
-func (c *connection) Init(filepath string){
-	b, err := ioutil.ReadFile(filepath)
-    if err != nil {
-      fmt.Print(err)
-    }
-    propJson := string(b)
-	var connProperties ConnectionProperties
-
-	json.Unmarshal([]byte(propJson), &connProperties)
-	fmt.Printf("Connection data:\n%s\n%s\n%s\n%s\n", connProperties.User, connProperties.Pass,connProperties.Host,connProperties.Db)
-	c.dBOpenStr = connProperties.User + ":" + connProperties.Pass + "@tcp(" + connProperties.Host + ")/" + connProperties.Db
-	fmt.Printf("Connecting with:\n%s\n", c.dBOpenStr)
-	db, err := sql.Open("mysql", c.dBOpenStr)
-
-	if err != nil {
-		panic(err)
-	}
-
-	defer db.Close()
-}
-
-func (c connection) LogIn(username string, password string) bool{
-	fmt.Printf("Connecting with:\n%s\n", c.dBOpenStr)
-	db, err := sql.Open("mysql", c.dBOpenStr)
-
-	if err != nil {
-		panic(err)
-	}
-
-	defer db.Close()
-
-	var counter int
-
-	act_query := "SELECT count(*) FROM gosite.users WHERE username='" + username + "' AND password='" + password + "';"
-	db.QueryRow(act_query).Scan(&counter)
-	fmt.Println("we have", counter, "rows")
-    
-    if (counter == 0) {
-    	return false
-    }
-	return true
-
-}
-
-/*
-func main() {
-
-	var dBConnector connection
-
-	dBConnector.Init("config.json")
-	if (dBConnector.LogIn("Alex", "09Alex09")) {
-		fmt.Printf("Succesfull logIn\n")
-	} else {
-		fmt.Printf("logIn error\n")
-	}
-
-	if (dBConnector.LogIn("Alax", "09Alex09")) {
-		fmt.Printf("Succesfull logIn\n")
-	} else {
-		fmt.Printf("logIn error\n")
-	}
-}
-*/