1

I have a Django application that reads different CSV files and saves them to the same model/table in the DB.

While fixtures are certainly used for setting up a test environment quickly, I used the fixture to configure the different CSV Schemata that is subsequently parsed by the Django application.

So each of the data provider has their own distinct schema which is a different row in the CsvSchema table.

During code review it came up that this is bad style because --

  1. It leads to duplication of data. I found it useful to pass such configurations via a fixture and treated it like a configuration file.
  2. To further treat the fixture like a configuration file, I even put it inside the git repository, which is again somethong the reviewer agrees with.
  3. The reviewer also claimed that fixtures should be use only once in the lifetime of the application, while setting it up initially.

To me, the fixtures are just a tool that Django provides us. I can play around with the schema details in my development machine, and then dump them into a fixture, effectively using it as configuration. Am I playing too hard and fast with the rules here?

Debanjan Basu
  • 834
  • 1
  • 8
  • 29
  • How are you loading CSV with fixtures when it doesn't seem to support that? It only supports JSON, XML and YAML... – little_birdie Dec 21 '21 at 23:47
  • Ahh.. I see, you have your own code which loads the csv file, but the metadata is in your CsvSchema.. one row for each file format... Well, I think this is not that bad if you are editing the file by hand anyway, but I would probably just write my own code for this since it would only be a few lines. – little_birdie Dec 21 '21 at 23:53
  • @little_birdie not sure what you mean. We get these CSV files from different vendors and the attempt had been to consolidate the data in one place. The Django service would enable people to upload the data they get from the vendor and keep a central source of information. – Debanjan Basu Dec 22 '21 at 05:07
  • Right, what I am asking you is whether you are using fixtures to load just the configuration for each vendor (into a configuration table) that is then used by your own code that loads the csv into a data table at a later time? Or, do you use fixtures to load the actual csv file into your data table? – little_birdie Dec 22 '21 at 20:06
  • Just the configuration for the vendor formats. – Debanjan Basu Dec 22 '21 at 20:14

0 Answers0