Finished all database related code

Sometimes it doesent delete the temporary database file
not tested on linux