-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust the database configuration format of the configuration file to…
… support the selection of MySQL and SQLite3. (#88) Signed-off-by: zhou_jiajian <[email protected]>
- Loading branch information
1 parent
9099061
commit 9527ae7
Showing
7 changed files
with
42 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* @Author: 周家建 | ||
* @Mail: [email protected] | ||
* @Date: 2021-07-27 19:02:39 | ||
* @Description: | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"strings" | ||
"database/sql" | ||
_ "github.com/go-sql-driver/mysql" | ||
_ "github.com/mattn/go-sqlite3" | ||
) | ||
|
||
func instanceDB(str string) (*sql.DB, error) { | ||
sp:= strings.Split(str, "://") | ||
if len(sp) == 2 { | ||
return sql.Open(sp[0], sp[1]) | ||
} else { | ||
return sql.Open("mysql", str) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters