Which file type should I use to store the python data

Asked

Viewed 149 times

-1

I am creating a program in Python that needs to store some settings and also need to save the data in a file of its own (Like Autocad that generates files in the format . DWG). So far I’ve used a database for both situations (I’ve put a database inside a file. ZIP because I need to store some pictures too).

But I do not know if this is the best option, because there are several others (.INI, .XML, .JSON, etc...). So, which is the best option?

Edit:

Besides storing the settings I also need to store some data in a proper extension (meu_file.banana for example) as when you create a document in Word, it will create a file . DOCX, which only WORD can read. I also want to know how to store the data in this case (I also need to store images in this case).

1 answer

2


For configuration storage, you can use the . conf and . ini extension using lib Configparser.

In case you need to save application data and images. You can use the SQLITE database, it is a local file database where the responsible for playing the role of DBMS are the own lib’s of python.

To do the image storage, the most suitable would be a proper repository for this because it is heavy data for a database, however, if you want to do this, you can transform your image into Base64 and save the resulting string in a field of bank blob, and perform disconnection when necessary.

If I come to use SQLITE, I direct you to use via ORM to facilitate its manipulation, an excellent library for this would be Sqlalchemy.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.