封裝mysql SDK
/*測試代碼 char**results; char**field new char*[4]; field[0] new char[64]; field[1] new char[64]; field[2] new char[64]; field[3] NULL; char*sn sn_id; char*name name; char*electricity request_count; strcpy_s(field[0], 64, sn); strcpy_s(field[1], 64, name); strcpy_s(field[2], 64, electricity); err seleteData(results, tableName, s_equipment_key, field); frees(field); frees(results); */ int selete_data(char**result, char* tableName, char* id, char**field) { MYSQL * sql get_mysql(); if (sql NULL) { printf(請連接數(shù)據(jù)庫!!!\n); return NULL; } /*----------------------------------------SELECT字符串拼接start--------------------------------------*/ char* select SELECT %s ; int length strlen(select) strlen(field[0]) - 1; char*sentence (char*)calloc(length, sizeof(char)); sprintf_s(sentence, length, select, field[0]); int count 0; pointer_count((void**)field, count); for (int i 1; i count; i) { select ,%s ; length strlen(sentence); append_new_buffer(sentence, length, select, strlen(select));//SELECT sn_id ,%s length strlen(sentence) strlen(field[i]) - 1; char*select_ (char*)calloc(length, sizeof(char)); sprintf_s(select_, length, sentence, field[i]);////SELECT sn_id ,na_id if (sentence ! NULL) { free(sentence); sentence NULL; } sentence select_; } select FROM %s WHERE id%s; length strlen(sentence); append_new_buffer(sentence, length, select, strlen(select));//SELECT sn_id ,%s length length strlen(tableName) strlen(id) - 3; char*sentence_ (char*)calloc(length, sizeof(char)); sprintf_s(sentence_, length, sentence, tableName, id); if (sentence ! NULL) { free(sentence); sentence NULL; } /*-------------------------------------SELECT字符串拼接end-----------------------------------------*/ int err mysql_real_query(sql, sentence_, length); if (sentence_ ! NULL) { free(sentence_); sentence_ NULL; } if (err) { printf(查詢時出錯: %s !!!\n, mysql_error(sql)); return -1; } MYSQL_RES *m_res NULL; m_res mysql_store_result(sql);//將結(jié)果保存在res結(jié)構(gòu)體中 //循環(huán)打印每行每個字段 MYSQL_ROW row NULL; row mysql_fetch_row(m_res); if (NULL row) { printf(沒有查詢到對應(yīng)的數(shù)據(jù)!!!\n); return -1; } result (char**)calloc(count 1, sizeof(char*)); unsigned int t; for (t 0; t mysql_num_fields(m_res); t) { int length strlen(row[t]) 1; result[t] (char*)calloc(length, sizeof(char)); strcpy_s(result[t], length, row[t]); } result[t] NULL; /*for (t 0; t count; t) { printf(%s:%s\n, field[t], result[t]); }*/ mysql_free_result(m_res); return 0; }這是最初版本。請移步github

相關(guān)新聞

vue中央事件總線bus

vue中央事件總線bus

全局 1、新建 eventBus.js 文件import Vue from vue export default new Vue()2、引用 (哪里要用就import eventBus.js 文件)$on : 監(jiān)聽 $emit :觸發(fā) $off : 釋放 ( 監(jiān)聽后一定要在beforeDestroy中釋放)

2026/7/28 19:54:23 閱讀更多
芯片設(shè)計CAD圖紙與TinyMCE集成的SVG解決方案

芯片設(shè)計CAD圖紙與TinyMCE集成的SVG解決方案

1. 芯片制造企業(yè)CAD圖紙與TinyMCE集成的核心挑戰(zhàn)在芯片設(shè)計領(lǐng)域,CAD圖紙是工程師的"設(shè)計語言"。我們每天需要將版圖(Layout)、原理圖(Schematic)等設(shè)計文件插入技術(shù)文檔系統(tǒng)。傳統(tǒng)截圖方式會導(dǎo)致&#xff1a…

2026/7/28 19:54:23 閱讀更多
第三十五周學(xué)習(xí)生活總結(jié)

第三十五周學(xué)習(xí)生活總結(jié)

今天是2019年9月1日,是開學(xué)的第一天,不過正好趕上周末,我們也沒有課。這是一個輕松地開始,但不代表是一個簡單的過程。 小組剛剛才把官網(wǎng)項目新聞模塊加載更多寫完,從昨天晚上寫到現(xiàn)在,雖說技術(shù)難度并不高&…

2026/7/28 19:44:22 閱讀更多
跨境支付系統(tǒng)架構(gòu)演進:從SWIFT到本地化清算通道

跨境支付系統(tǒng)架構(gòu)演進:從SWIFT到本地化清算通道

背景:跨境支付為什么這么慢?做過跨境支付系統(tǒng)開發(fā)的工程師應(yīng)該都有體會——一筆從國內(nèi)到海外的資金,動輒3到5個工作日才能到賬。問題不出在銀行系統(tǒng)慢,出在底層架構(gòu)上。傳統(tǒng)跨境支付走的是SWIFT網(wǎng)絡(luò)。資金從匯款行出發(fā)&#xff0c…

2026/7/29 5:36:05 閱讀更多
Pandas數(shù)據(jù)處理實戰(zhàn):從Series與DataFrame基礎(chǔ)到完整工作流

Pandas數(shù)據(jù)處理實戰(zhàn):從Series與DataFrame基礎(chǔ)到完整工作流

1. 項目概述:從闖關(guān)實驗看數(shù)據(jù)處理核心技能最近在“頭歌”平臺上帶學(xué)生過Python數(shù)據(jù)處理實驗,發(fā)現(xiàn)很多新手卡在了數(shù)據(jù)框和序列的基本操作上。這其實是個挺普遍的現(xiàn)象:大家學(xué)Python數(shù)據(jù)分析,一上來就被pandas庫的DataFrame和Series…

2026/7/29 5:36:05 閱讀更多
智能Bot產(chǎn)品核心價值定位與實戰(zhàn)框架

智能Bot產(chǎn)品核心價值定位與實戰(zhàn)框架

1. Clawdbot的啟示:智能Bot產(chǎn)品的核心價值定位第一次接觸Clawdbot時,最讓我驚訝的是它解決實際業(yè)務(wù)痛點的精準(zhǔn)度。這個智能Bot沒有堆砌花哨的AI功能,而是聚焦于企業(yè)決策層的核心需求——通過自動化數(shù)據(jù)抓取和智能分析,將分散在各系…

2026/7/29 5:26:04 閱讀更多
面試官大笑:“一個任務(wù)拆給 5 個 Subagent 并行跑,不比 1 個快 5 倍?“我搖頭:“快不了,還可能更慢“

面試官大笑:“一個任務(wù)拆給 5 個 Subagent 并行跑,不比 1 個快 5 倍?“我搖頭:“快不了,還可能更慢“

前兩個月,我在重構(gòu) AlgoMooc 網(wǎng)站過程中,發(fā)現(xiàn)一個問題:在 Claude Code 里把一個任務(wù)拆給 5 個 Subagent 并行跑,結(jié)果可能比 1 個 agent 從頭干到尾還慢? 大多數(shù)人的第一反應(yīng)是反過來的:活是并行干的&#…

2026/7/29 0:15:24 閱讀更多
# 鴻蒙 HarmonyOS 應(yīng)用開發(fā)實戰(zhàn)(第25期)|骰子(Dice Roller)— Unicode 符號與動畫渲染精講

# 鴻蒙 HarmonyOS 應(yīng)用開發(fā)實戰(zhàn)(第25期)|骰子(Dice Roller)— Unicode 符號與動畫渲染精講

一、應(yīng)用概述 骰子(Dice Roller) 是一款經(jīng)典的休閑娛樂應(yīng)用,模擬了真實擲骰子的過程。應(yīng)用投擲兩個骰子(六面標(biāo)準(zhǔn)骰),使用 Unicode 骰面符號直觀展示每個骰子的點數(shù),并伴有快速滾動的動畫效果。…

2026/7/29 0:15:24 閱讀更多