成长记录——SQL脚本转换工具

写在前面:

成长记录——SQL脚本转化工具

  • 工作中需要用到.xlsx格式文件转换成.db格式数据库,手动导表麻烦,而且容易出错,为方便数据库的批量导入和读取,并且完成软件部署,下面介绍一款自用批量CVS转SQL脚本工具。

#include "chiness.h"
//获取_inFile文件的一行
#define GET_LINE(_inFile, _line, _lineLen, _strLine) \
                    memset(_line, 0, _lineLen); \
                    _inFile.getline(_line, _lineLen); \
                    _strLine = string(_line, strlen(_line)); \
                    removeR(_strLine)

#define ADDRESS_REGEX_MATCH(_addr, _result) \
        regex _reg("[A-Z]*[0-9]*\\.{0,1}[0-9]+");\
        _result = regex_match(_addr, _reg)

template<class... T>
void unused_parameter(T&&...) {
   }
using namespace std;

string g_sqlPath;
string g_oneSqlFileName = "allSqls.sql";
string g_strTimestamp;

void removeR(string& source)
{
   
    regex g("\\r");
    source = regex_replace(source, g, "");
}

string GetExePath(void)
{
   
	char szFilePath[MAX_PATH + 1] = {
    0 };
	GetModuleFileNameA(NULL, szFilePath, MAX_PATH);
	(strrchr(szFilePath, '\\'))[0] = 0; // 删除文件名,只获得路径字串  
	string path = szFilePath;
	
    regex reg("\\\\");
    path = regex_replace(path, reg, "/");

	return path;
}

void removeSpace(string& source)
{
   
    string::size_type pos1 = source.find(" ");
    if (pos1 != string::npos && pos1 == 0)
    {
   
        source = source.substr(1);
    }

    string::size_type pos2 = source.rfind(" ");
    if (pos2 != string::npos && source.length() - pos2 == 1)
    {
   
        source.pop_back();
    }

    if(source.find(" ") != string::npos)
        removeSpace(source);
}

string findKey(const string& source, const string& key, string& buttonName)
{
   
    string::size_type pos = source.rfind(key);
    string result;
    if (pos != string::npos && (source.length() - pos <= 4))
    {
   
        buttonName = source.substr(pos);
        result = source.substr(0, pos);
    }

    return result;
}

string findName(const string& source, string& buttonName)
{
   
    string r = findKey(source, "启动", buttonName);
    if (!r.empty())
        return r;
    r = findKey(source, "停止", buttonName);
    if (!r.empty())
        return r;

    r = findKey(source, "自动", buttonName);
    if (!r.empty())
        return r;
    r = findKey(source, "手动", buttonName);
    if (!r.empty())
        return r;

    r = findKey(source, "松开", buttonName);
    if (!r.empty())
        return r;
    r = findKey(source, "胀紧", buttonName);
    if (!r.empty())
        return r;

    r = findKey(source, "下降", buttonName);
    if (!r.empty())
        return r;
    r = findKey(source, "上升", buttonName);
    if (!r.empty())
        return r;

    r = findKey(source, "伸出", buttonName);
    if (!r.empty())
        return r;
    r = findKey(source, "回缩", buttonName);
    if (!r.empty())
        return r
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值