Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Unsupported DATABASE_TYPE: postgres #50

Closed
ramkrishna757575 opened this issue Sep 7, 2023 · 2 comments
Closed

ValueError: Unsupported DATABASE_TYPE: postgres #50

ramkrishna757575 opened this issue Sep 7, 2023 · 2 comments

Comments

@ramkrishna757575
Copy link
Contributor

ramkrishna757575 commented Sep 7, 2023

When setting this project up, and following the documentation under the How to start using gpt-pilot? section, the documentation at step number 8 mentions setting up the environment variable in the .env file.

Here it mentions the following:

to change from SQLite to PostgreSQL in your .env just set DATABASE_TYPE=postgres

But this results in an error:

Traceback (most recent call last):
  File "/home/ramkrishna/Documents/experiments/gpt-pilot/pilot/db_init.py", line 5, in <module>
    drop_tables()
  File "/home/ramkrishna/Documents/experiments/gpt-pilot/pilot/database/database.py", line 385, in drop_tables
    raise ValueError(f"Unsupported DATABASE_TYPE: {DATABASE_TYPE}")
ValueError: Unsupported DATABASE_TYPE: postgres

The error seems to be due to this check in pilot/database/database.py:380

            if DATABASE_TYPE == "postgresql":
                sql = f'DROP TABLE IF EXISTS "{table._meta.table_name}"'
            elif DATABASE_TYPE == "sqlite":
                sql = f'DROP TABLE IF EXISTS "{table._meta.table_name}"'
            else:
                raise ValueError(f"Unsupported DATABASE_TYPE: {DATABASE_TYPE}")

The correct check should be:

            if DATABASE_TYPE == "postgres":
                sql = f'DROP TABLE IF EXISTS "{table._meta.table_name}"'
            elif DATABASE_TYPE == "sqlite":
                sql = f'DROP TABLE IF EXISTS "{table._meta.table_name}"'
            else:
                raise ValueError(f"Unsupported DATABASE_TYPE: {DATABASE_TYPE}")
@ramkrishna757575
Copy link
Contributor Author

Should I go ahead and create a PR for this fix?

@zvone187
Copy link
Contributor

zvone187 commented Sep 7, 2023

Yes, please do - great catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants