<commit_before>#include "util.h"

#include <mysql++.h>

#include <iostream>
#include <iomanip>

using namespace std;

int
main(int argc, char *argv[])
{
	// The full format for the Connection constructor is
	// Connection(cchar *db, cchar *host="", 
	//            cchar *user="", cchar *passwd="") 
	// You may need to specify some of them if the database is not on
	// the local machine or you database username is not the same as your
	// login name, etc..
	try {
		mysqlpp::Connection con(mysqlpp::use_exceptions);
		if (!connect_sample_db(argc, argv, con)) {
			return 1;
		}

		mysqlpp::Query query = con.query();
		// This creates a query object that is bound to con.

		query << "select * from stock";
		// You can write to the query object like you would any other ostrem

		mysqlpp::Result res = query.store();
		// Query::store() executes the query and returns the results

		cout << "Query: " << query.preview() << endl;
		// Query::preview() simply returns a string with the current query
		// string in it.

		cout << "Records Found: " << res.size() << endl << endl;

		mysqlpp::Row row;
		cout.setf(ios::left);
		cout << setw(17) << "Item"
			<< setw(4) << "Num"
			<< setw(7) << "Weight"
			<< setw(7) << "Price" << "Date" << endl << endl;

		mysqlpp::Result::iterator i;
		// The Result class has a read-only Random Access Iterator
		for (i = res.begin(); i != res.end(); i++) {
			row = *i;
			cout << setw(17) << row[0].c_str()
				<< setw(4) << row[1].c_str()
				<< setw(7) << row.lookup_by_name("weight").c_str()
				// you can use either the index number or column name when
				// retrieving the colume data as demonstrated above.
				<< setw(7) << row[3].c_str()
				<< row[4] << endl;
		}
	}
	catch (mysqlpp::BadQuery& er) {
		// handle any connection or query errors that may come up
#ifdef USE_STANDARD_EXCEPTION
		cerr << "Error: " << er.what() << endl;
#else
		cerr << "Error: " << er.error << endl;
#endif
		return -1;<commit_msg>Reworked the code style.<commit_after>#include "util.h"

#include <mysql++.h>

#include <iostream>
#include <iomanip>

using namespace std;

int
main(int argc, char *argv[])
{
	try {
		mysqlpp::Connection con(mysqlpp::use_exceptions);
		if (!connect_sample_db(argc, argv, con)) {
			return 1;
		}

		// Create a query object that is bound to con.
		mysqlpp::Query query = con.query();

		// You can write to the query object like you would any other
		// ostream.
		query << "select * from stock";

		// Display the query string.
		cout << "Query: " << query.preview() << endl;

		// Execute the query and save the results
		mysqlpp::Result res = query.store();
		cout << "Records Found: " << res.size() << endl << endl;

		// Display the result table header.
		cout.setf(ios::left);
		cout << setw(17) << "Item" <<
				setw(4) << "Num" <<
				setw(7) << "Weight" <<
				setw(7) << "Price" << "Date" << endl << endl;

		// Use the Result class's read-only random access iterator to 
		// step through the results.
		mysqlpp::Row row;
		mysqlpp::Result::iterator i;
		for (i = res.begin(); i != res.end(); i++) {
			row = *i;
			// Note that you can use either the column index or name
			// to retrieve the data.
			cout << setw(17) << row[0].c_str() <<
					setw(4) << row[1].c_str() <<
					setw(7) << row.lookup_by_name("weight").c_str() <<
					setw(7) << row[3].c_str() <<
					row[4] << endl;
		}
	}
	catch (mysqlpp::BadQuery& er) {
		// handle any connection or query errors that may come up
#ifdef USE_STANDARD_EXCEPTION
		cerr << "Error: " << er.what() << endl;
#else
		cerr << "Error: " << er.error << endl;
#endif
		return -1;
{'fraction_non_alphanumeric': 0.16953863257365204, 'fraction_numerical': 0.008893829905503057, 'mean_word_length': 3.1463133640552994, 'pattern_counts': {'":': 0, '<': 149, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4397303', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1228, 'n_words': 400}