This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
packageCommonDao
import(
"dsAutoCode/Utils/ConfigUtil"
"dsAutoCode/Utils/DbUtil"
)
vardb=DbUtil.Engine
/**
功能:获取指定表格的主键
作者:黄海
时间:2020-05-30
*/
funcGetTablePk(tableNamestring)(string,string){
sql:="select column_name from information_schema.`key_column_usage` where table_name='"+tableName+"' and constraint_name='primary' and constraint_schema='"+ConfigUtil.WorkingDataBase+"'"
list,_:=db.SQL(sql).Query().List()
pk:=list[0]["column_name"].(string)
//主键的数据类型
sql="select data_type from information_schema.columns where table_name = '"+tableName+"' and table_schema = '"+ConfigUtil.WorkingDataBase+"' and column_name='"+pk+"'"