dbTalk Databases Forums  

Buffer Problems?

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Buffer Problems? in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Della Vecchia
 
Posts: n/a

Default Buffer Problems? - 12-21-2006 , 02:40 PM






Hi, ive been having this problem, and I believe i've narrowed it down to=
=

something im doing wrong with mysqlpp.

I've asked on other forums and they told me they dont know whats wrong =

because, barring mysqlpp, my code is fine.

The problem is: This loop runs every 5 seconds and my intention is to =

write to a file the results of the query each iteration, however, this =

file keeps growing bigger and bigger instead of being truncated to 0 eac=
h =

time and starting over from scratch. I've tried flushing the file, using=
=

ofstream::trunc while opening, and as far as i know, the ofstream handle=
r =

is doing its job. The file is opened and truncated, however when i write=
=

to the file (using <<), it writes all data that has been written in the =
=

past as well as any new data (i assume there is some buffer that never =

gets cleared), this is my problem.

I know it may seem confusing, maybe my spaghetti code will clear things =
up =



------------------------------------------------------------------------=
------
#include "util.h"
#include <mysql++.h>
#include <custom.h>
#include "tastatus_ssqls.h"
#include <iostream>
#include <iomanip>
#include <vector>
#include <fstream>

using namespace std;
using namespace mysqlpp;

int main(int argc, const char *argv[]) {
vector<tastatus> ta;
char delim[5] =3D ",";
cout << "Connecting to MySQL...";
Connection conn("--EDITED--","--EDITED--","--EDITED--","--EDITED--");=

cout << "success!" << endl;
Query ta_status =3D conn.query();
string query =3D "SELECT * FROM --EDITED--";
int run =3D 0;
while (run < 1) { //Run forever
ofstream tafile("tafile.txt");
//ofstream tafile("tafile.txt", ofstream:ut | ofstream::trunc); /=
/ =

This doesnt make a difference
ta_status << query;
ta_status.storein(ta);
for (vector<tastatus>::iterator it =3D ta.begin(); it !=3D ta.end()=
; ++it) =

{
tafile << it->address << delim << it->status << delim << =

it->last_req << delim << it->last_command << delim << it->updated << end=
l; =

//basically creating a CSV
}
sleep(5); //Loop every 5 seconds...
//tafile.flush(); //no difference
//cout.flush(); //no difference
//tafile.close(); // This doesnt make a difference either
}
conn.close();
return 0;
}
------------------------------------------------------------------------=
---------------

Here is my SSQLS declaration (inside "tastatus_ssqls.h"):

------------------------------------------------------------
sql_create_6(tastatus, 1, 0,
mysqlpp::sql_char, address,
mysqlpp::sql_char, host,
mysqlpp::sql_char, status,
mysqlpp::sql_int, last_req,
mysqlpp::sql_char, last_command,
mysqlpp::sql_char, updated)
------------------------------------------------------------

Thanks for any help!,
-- =

David Della Vecchia
Vacation Express
davidd (AT) vacationexpress (DOT) com

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Warren Young
 
Posts: n/a

Default Re: Buffer Problems? - 12-22-2006 , 05:52 AM






David Della Vecchia wrote:
Quote:
The problem is: This loop runs every 5 seconds and my intention is to
write to a file the results of the query each iteration, however, this
file keeps growing bigger and bigger instead of being truncated to 0
each time and starting over from scratch.
I don't see how this can be a MySQL++ problem, since MySQL++ doesn't
deal in files.

Why don't you try removing all the MySQL++ stuff, and then just writing
random data to the file where you'd normally insert data from the result
set? Keep the loop structure, build options, etc. the same. What happens?

If you still get the same bug, can you please recast the program in
terms of the sample database, so people can try it on their machines?

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Warren Young
 
Posts: n/a

Default Re: Buffer Problems? - 12-22-2006 , 05:55 AM



Warren Young wrote:
Quote:
If you still get the same bug, can you please recast the program in
terms of the sample database, so people can try it on their machines?
Sorry, I meant to say that if the bug goes away when you remove MySQL++
from the picture, please try to recreate it by modifying one of the
examples. There's little we can do to help you without runnable code,
and that requires your database the way you've currently formulated the
problem report.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.