OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

I can't figure out what the error is, when applying migration on the django server, I'm trying to connect a PostgreSQL database

  • Thread starter Thread starter user532577
  • Start date Start date
U

user532577

Guest
the error looks like this, Unable to connect to PostgreSQL: Traceback (most recent call last):your text File "manage.py", line 22, in main()your text File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\core\management_init_.py", line 442, in execute_from_command_line utility.execute() File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\core\management_init_.py", line 436, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\core\management\base.py", line 412, in run_from_argv self.execute(*args, **cmd_options) File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\core\management\base.py", line 458, in execute output = self.handle(*args, **options) File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\core\management\base.py", line 106, in wrapper res = handle_func(*args, **kwargs) File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\core\management\commands\migrate.py", line 117, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\migrations\executor.py", line 18, in init self.loader = MigrationLoader(self.connection) File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\migrations\loader.py", line 58, in init self.build_graph() File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\migrations\loader.py", line 235, in build_graph self.applied_migrations = recorder.applied_migrations() File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\migrations\recorder.py", line 81, in applied_migrations if self.has_table(): File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\migrations\recorder.py", line 57, in has_table with self.connection.cursor() as cursor: File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\backends\base\base.py", line 330, in cursor return self._cursor() File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\backends\dummy\base.py", line 20, in complain raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

the settings file with a fragment of the database settings looks like this

Code:
load_dotenv()

print("Database Name:", os.getenv('FSTR_DB_NAME'))
print("Database User:", os.getenv('FSTR_DB_USER'))
print("Database Password:", os.getenv('FSTR_DB_PASSWORD'))
print("Database Host:", os.getenv('FSTR_DB_HOST'))
print("Database Port:", os.getenv('FSTR_DB_PORT'))

BASE_DIR = Path(file).resolve().parent.parent

Code:
# Настройки базы данных
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': os.getenv('FSTR_DB_NAME'),
        'USER': os.getenv('FSTR_DB_USER'),
        'PASSWORD': os.getenv('FSTR_DB_PASSWORD'),
        'HOST': os.getenv('FSTR_DB_HOST'),
        'PORT': os.getenv('FSTR_DB_PORT'),
    }
}

I also have a file.an env that contains all the data that is needed to connect.

I must say right away, I need to get the data through the environment variables. I have never encountered this and have never worked with it, if there are any sources that talk about it, I will only be glad if someone gives me a link that tells me how to do everything right.
<p>the error looks like this,
Unable to connect to PostgreSQL:
Traceback (most recent call last):<code>your text</code>
File "manage.py", line 22, in
main()<code>your text</code>
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\core\management_<em>init</em>_.py", line 442, in execute_from_command_line
utility.execute()
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\core\management_<em>init</em>_.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\core\management\base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\core\management\base.py", line 458, in execute
output = self.handle(*args, **options)
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\core\management\base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\core\management\commands\migrate.py", line 117, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\migrations\executor.py", line 18, in <strong>init</strong>
self.loader = MigrationLoader(self.connection)
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\migrations\loader.py", line 58, in <strong>init</strong>
self.build_graph()
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\migrations\loader.py", line 235, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\migrations\recorder.py", line 81, in applied_migrations
if self.has_table():
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\migrations\recorder.py", line 57, in has_table
with self.connection.cursor() as cursor:
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\backends\base\base.py", line 330, in cursor
return self._cursor()
File "C:\python\SkillFactory\Sprint\env\lib\site-packages\django\db\backends\dummy\base.py", line 20, in complain
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.</p>
<p>the settings file with a fragment of the database settings looks like this</p>
<pre><code>load_dotenv()

print("Database Name:", os.getenv('FSTR_DB_NAME'))
print("Database User:", os.getenv('FSTR_DB_USER'))
print("Database Password:", os.getenv('FSTR_DB_PASSWORD'))
print("Database Host:", os.getenv('FSTR_DB_HOST'))
print("Database Port:", os.getenv('FSTR_DB_PORT'))
</code></pre>
<p>BASE_DIR = Path(<strong>file</strong>).resolve().parent.parent</p>
<pre><code># Настройки базы данных
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv('FSTR_DB_NAME'),
'USER': os.getenv('FSTR_DB_USER'),
'PASSWORD': os.getenv('FSTR_DB_PASSWORD'),
'HOST': os.getenv('FSTR_DB_HOST'),
'PORT': os.getenv('FSTR_DB_PORT'),
}
}
</code></pre>
<p>I also have a file.an env that contains all the data that is needed to connect.</p>
<p>I must say right away, I need to get the data through the environment variables. I have never encountered this and have never worked with it, if there are any sources that talk about it, I will only be glad if someone gives me a link that tells me how to do everything right.</p>
 

Latest posts

Top