Dear OF people,
ofxMySQL has some minor challenges for the connection. Here is the brief explanation for the solution for Mac Users
- ofxMySQL.h needs the following change
void connect(string hostname, string username, string password, string dbname, int port);
in port is required, otherwise no success
similarly
2) same function in cpp needs a change with port settings, I have it be 8889 since it is the default setting for my MAMP
void ofxMySQL::connect(string hostname, string username, string password, string dbname="", int port=8889)
{
if (isConnected)
mysql_close(_db);
isConnected = mysql_real_connect(_db,hostname.c_str(),username.c_str(),password.c_str(),dbname.c_str(),port,NULL,0);
if (!isConnected)
{
ofLog(OF_LOG_ERROR, “ofxMySQL: Connection failed to database '” + dbname + "’ on host " + hostname);
reportError();
} else
ofLog(OF_LOG_VERBOSE, “ofxMySQL: Successfully connected to database '” + dbname + "’ on host " + hostname);
}
now it should connect.
here is the query calls for those who want to gather entries from the tables.
db.ofxMySQL::connect(“127.0.0.1”, “root”, “root”, “FilikaTwitter”,8889);
string querystring = “SELECT * FROM tweets”;
cout << db.getStrings(id_str, “tweets”, “id_str”) << endl;
cout << db.getStrings(screen_name, “tweets”, “screen_name”) << endl;
cout << db.getStrings(tweet_text, “tweets”, “tweet_text”) << endl;
cout << db.getStrings(created_at, “tweets”, “created_at”) << endl;
However yet there is some sort of problem that I was not able to solve. Being a non-English speaking person, I need to gather data from my mySQL server with UTF8 encoding. But with that I was not able to move ahead. Entries are clear with all proper characters in mySQL or with a Php call, but as soon as I access them with oF, they are no longer proper. I will be grateful for those who would suggest me a solution.
Thanks in advance