<commit_before>// syscfg
package main

import (
	"crypto/md5"
	"database/sql"
	"encoding/hex"
	"fmt"

	_ "github.com/mattn/go-sqlite3"
)

var (
	sysCfgDb              *sql.DB
	sysDbErr              error
	DbName                = "bdgfcsys"
	SysTabCreate_sys_user = `		
		CREATE TABLE IF NOT EXISTS sys_user 
		(
			--id 			INTEGER PRIMARY KEY AUTOINCREMENT,
			user_id		VARCHAR(128) PRIMARY KEY NOT NULL,
			user_pass 	VARCHAR(128) NOT NULL,
			user_sign	VARCHAR(32) DEFAULT NULL,
			trustzone	VARCHAR(256) DEFAULT NULL,
			user_status	INTEGER DEFAULT 1 NOT NULL,
			last_login 	DATETIME DEFAULT NULL,
			create_time DATETIME DEFAULT(DATETIME('now', 'localtime')) NOT NULL
		);`
	sysTab_sys_user_list    = `select * from sys_user`
	sysTab_sys_user_add     = `insert into sys_user(user_id,user_pass) values(?,?)`
	sysTab_sys_user_Login   = `update sys_user set last_login=DATETIME('now', 'localtime') where user_id=? and user_pass=?`
	sysTab_sys_user_SetPass = `update sys_user set user_pass=? where user_id=? and user_pass=?`

	SysTabCreate_sys_cfg = `		
		CREATE TABLE IF NOT EXISTS sys_method 
		(
			--id 			INTEGER PRIMARY KEY AUTOINCREMENT,
			method_name		VARCHAR(128) PRIMARY KEY NOT NULL,
			method_content 	VARCHAR(128) NOT NULL,
			dbdriver		VARCHAR(32) DEFAULT NULL,
			update_time 	DATETIME DEFAULT NULL,
			create_time 	DATETIME DEFAULT(DATETIME('now', 'localtime')) NOT NULL
		);`
	sysTab_sys_method_list         = `select method_name,method_content,dbdriver from sys_method`
	sysTab_sys_method_add          = `insert into sys_method(method_name,method_content,dbdriver) values(?,?,?)`
	sysTab_sys_method_Content_Set  = `update sys_method set method_content=? where method_name=?`
	sysTab_sys_method_Dbdriver_set = `update sys_method set dbdriver=? where method_name=?`
)

func init() {
	sysCfgDb = OpenDb("sqlite3", DbName)
	if sysCfgDb == nil {
		panic("open db error")
	}
	_, sysDbErr := sysCfgDb.Exec(SysTabCreate_sys_user)
	if nil != sysDbErr {
		fmt.Println(sysDbErr.Error())
	}

	AddUser("jhf", "123")
	AddUser("tf", "tfpass")
	PrinTab(sysCfgDb, sysTab_sys_user_list)

	ChangeUserPass("jhf", "123", "3456")
	PrinTab(sysCfgDb, sysTab_sys_user_list)
}

func str2md5(str string) string {
	sum := md5.Sum([]byte(str))
	return hex.EncodeToString(sum[:])
}

func chekError(err error, output bool) bool {
	if err != nil {
		if output {
			fmt.Println(err.Error())<commit_msg>add sqlite<commit_after>// syscfg
package main

import (
	"crypto/md5"
	"database/sql"
	"encoding/hex"
	"fmt"

	_ "github.com/mattn/go-sqlite3"
)

var (
	sysCfgDb              *sql.DB
	sysDbErr              error
	DbName                = "bdgfcsys"
	SysTabCreate_sys_user = `		
		CREATE TABLE IF NOT EXISTS sys_user 
		(
			--id 			INTEGER PRIMARY KEY AUTOINCREMENT,
			user_id		VARCHAR(128) PRIMARY KEY NOT NULL,
			user_pass 	VARCHAR(128) NOT NULL,
			user_sign	VARCHAR(32) DEFAULT NULL,
			trustzone	VARCHAR(256) DEFAULT NULL,
			user_status	INTEGER DEFAULT 1 NOT NULL,
			last_login 	DATETIME DEFAULT NULL,
			create_time DATETIME DEFAULT(DATETIME('now', 'localtime')) NOT NULL
		);`
	sysTab_sys_user_list    = `select * from sys_user`
	sysTab_sys_user_add     = `insert into sys_user(user_id,user_pass) values(?,?)`
	sysTab_sys_user_Login   = `update sys_user set last_login=DATETIME('now', 'localtime') where user_id=? and user_pass=?`
	sysTab_sys_user_SetPass = `update sys_user set user_pass=? where user_id=? and user_pass=?`

	SysTabCreate_sys_cfg = `		
		CREATE TABLE IF NOT EXISTS sys_method 
		(
			--id 			INTEGER PRIMARY KEY AUTOINCREMENT,
			method_name		VARCHAR(128) PRIMARY KEY NOT NULL,
			method_content 	VARCHAR(128) NOT NULL,
			dbdriver		VARCHAR(32) DEFAULT NULL,
			update_time 	DATETIME DEFAULT NULL,
			create_time 	DATETIME DEFAULT(DATETIME('now', 'localtime')) NOT NULL
		);`
	sysTab_sys_method_list         = `select method_name,method_content,dbdriver from sys_method`
	sysTab_sys_method_add          = `insert into sys_method(method_name,method_content,dbdriver) values(?,?,?)`
	sysTab_sys_method_Content_Set  = `update sys_method set method_content=? where method_name=?`
	sysTab_sys_method_Dbdriver_set = `update sys_method set dbdriver=? where method_name=?`
)

func init() {

	sysCfgDb = OpenDb("sqlite3", DbName)
	if sysCfgDb == nil {
		panic("open db error")
	}

	ModifyTab(sysCfgDb, SysTabCreate_sys_user)

	AddUser("jhf", "123")
	AddUser("tf", "tfpass")
	PrinTab(sysCfgDb, sysTab_sys_user_list)

	ChangeUserPass("jhf", "<PASSWORD>", "<PASSWORD>")
	PrinTab(sysCfgDb, sysTab_sys_user_list)
}

func str2md5(str string) string {
	sum := md5.Sum([]byte(str))
	return hex.EncodeToString(sum[:])
}

func chekError(err error, output bool) bool {
	if err != nil {
		if output {
			fmt.Println(err.Error())
{'fraction_non_alphanumeric': 0.10817104149026249, 'fraction_numerical': 0.01375952582557155, 'mean_word_length': 4.297085201793722, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5544554', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1761, 'n_words': 394}