factorio-learning-environment icon indicating copy to clipboard operation
factorio-learning-environment copied to clipboard

Sqlite db default

Open hrshtt opened this issue 6 months ago • 1 comments

Moved db creation logic to db_client.py file. Added table creation logic for both postgres and sqlite in new methods, that are then called in the existing create_db_client method.

Added a new .env variable to let the user select between sqlite and postgres. Replaced Child db classes with the parent DB Client class across the project, so that the db is dynamically maintained across everywhere.

Tested manually with db creation checks, data entry checks from running lab play experiments.

updated README to reflect the simplifications made in the overall steps.

implements #210

hrshtt avatar May 30 '25 21:05 hrshtt

ABC usage in db_client is confusing, given no abstract classes are declared this leads to linter issues and is generally a bad pattern. I did not touch it as i dont know the intent here.

hrshtt avatar May 30 '25 21:05 hrshtt

Looking at the readme, it seems that we ask the user to replace the PostgresDB client in code with an SQLite client as part of the setup process.

I think it would be better to use a factory pattern to select the client depending on the DB connection string (which is usually prefixed with the SQL flavour) so no user needs to modify code to get started.

What do you think @hrshtt @kantneel ?

JackHopkins avatar Jun 18 '25 15:06 JackHopkins

Looking at the readme, it seems that we ask the user to replace the PostgresDB client in code with an SQLite client as part of the setup process.

I think it would be better to use a factory pattern to select the client depending on the DB connection string (which is usually prefixed with the SQL flavour) so no user needs to modify code to get started.

What do you think @hrshtt @kantneel ?

If you are referring to line 201 from the readme, then it is being removed in this pr, or is it somewhere else?

kiankyars avatar Jun 19 '25 09:06 kiankyars

Looking at the readme, it seems that we ask the user to replace the PostgresDB client in code with an SQLite client as part of the setup process.

I think it would be better to use a factory pattern to select the client depending on the DB connection string (which is usually prefixed with the SQL flavour) so no user needs to modify code to get started.

What do you think @hrshtt @kantneel ?

In the PR i have added an explicit environment variable to select a db and the code then uses the factory to spawn the appropriate db class.

the comment on the db_client.py:ln740 from @MortenTobiasNielsen should now be resolved

hrshtt avatar Jun 19 '25 10:06 hrshtt