S
S
S1NYAA2021-11-01 15:35:27
Python
S1NYAA, 2021-11-01 15:35:27

Why does it throw an error 'NoneType' object has no attribute 'startswith'?

I want to use code -

import aiohttp
import os
import re

uri = os.getenv("DB_URL")
if uri.startswith("postgres://"):
    uri = uri.replace("postgres://", "postgresql://", 1)
    DB_URL = 'postgresql://postgres:[email protected]:5432/parser'


And he gave me an error - Traceback (most recent call last): File "C:/Users/sinto/PycharmProjects/OLX/main.py", line 12, in import config File "C:\Users\sinto\PycharmProjects\OLX\ config.py", line 6, in if uri.startswith("postgres://"): AttributeError: 'NoneType' object has no attribute 'startswith'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-11-01
@S1NYAA

DB_URL environment variable not set means.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question