Binary File Handling Sucks.. Need help

I am currently trying to make a database type program where I keep the details of a Sweet Shop…

I used file handling as I wanted some challenge and I don’t know MySQL connectivity… This part of the code is giving me problem as it doesn’t dump data into my *.dat file. Line 20 of the same module does save the data so i know there isn’t an error with my file but i cant figure out how do I make the data get saved.

Would be glad if someone helped… <3

(P.S: Open for the code to start, also I dont know if you can see the enitre repository if i link just 1 line so posting the link for the repository too.)

My thinking is that the dump is happening to file but you aren’t managing the file right. I’m only looking at this code, but my suggestion is you take all of your data management stuff and you push it into a .py file that you import. Then instead of hand coding every create, read, update, delete operation right inside every handler, you just call a function that does it all for you. You can then write a test to make sure that it works.

Next, you don’t need mysql to do some sql. Python 3 comes with sqlite built in:

Try that out if you know sql but don’t want to run a whole server and stuff. It’s a very powerful, very fast, very well supported database that just runs in a file.

1 Like

Thank you for the response, I was able to fix the code by the best method, rewrite the code. The sad part is that I couldn’t find the part where i went wrong. Also, I tried SQLite and its freaking insane. Would recommend it to anyone. <3<3

That happens. I sometimes just give up and delete and start over.

1 Like