我想编写一个命令行工具,该工具将允许我输入命令和变量,然后该工具将返回来自SQL数据库的信息
我已经用Xcode创建了一个项目,安装了mysql-connector-c ++并使用自制软件进行了增强,但是每当我尝试包含标头时,它都不允许我进行编译,我什至尝试使用确切的路径
#include <iostream>
#include "boost/shared_ptr.hpp"
#include "boost/smart_ptr/shared_ptr.hpp"
#include "/usr/local/mysql-connector-c++/include/jdbc/mysql_connection.h"
#include "/usr/local/mysql-connector-c++/include/jdbc/mysql_driver.h"
#include "/usr/local/mysql-connector-c++/include/jdbc/mysql_error.h"
我不确定自己在做什么错
答案 0 :(得分:0)
我建议使用php一个简单的程序;我不确定c ++,但语言可能相似;
保存一个example.php文件:
<?php
error_reporting(~E_WARNING);
date_default_timezone_set('Asia/Taiwan');
// include files for required variables ;
$mysqli = new mysqli($Host, $User, $Password, $CustomerDB);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$arrayReceive = array();
if (!isset($_SESSION)){session_start();}
$sql = "select * from $DB.customeritem where Status='ACTIVE'";
$res = $mysqli->query($sql);
if (!$res){echo "Failed query Line18customeritem: (".$mysqli->errno.") ". $mysqli->error;}
echo "No. of customeritems : ".$res->num_rows."\r\n";
while($row=$res->fetch_assoc()){
// code to handle each row return from mysql query ;
}//end while
$_SESSION["customeritemArray"] = $customeritemArray;
// $mysqli->close();
?>
然后命令行工具可以输入: php -f C:\ wamp64 \ www \ projectFolder \ example.php
或者您可以将其设为脚本。
答案 1 :(得分:-1)
我已经在mysql连接器文档中看到,包含的内容正确:
python app\idol\content\testcontent.py
请确保没有“” ,它是 <>