sqlalchemy showing an error related to os.getenv()












-3















I am working on sqlalchemy and there's command in it engine -
create_engine(os.getenv("DATABASE_URL")).



When I run the program it shows an error saying -




"Could not parse rfc1738 URL from string 'C:Program Files PostgreSQL10data"




Code



import os

from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker

#engine = create_engine('sqlite://')
engine = create_engine(os.getenv("DATABASE_URL"))
db = scoped_session(sessionmaker(bind=engine))

def main():
flights = db.execute("SELECT origin, destinaiton, duration FROM flights").fetchall()
for flights in flights:
print(f"{flight.origin} to {flight.destination}, {flight.duration} minutes.")

if __name__ == "__main__":
main()


Error




Traceback (most recent call last): File "list.py", line 7, in

engine = create_engine(os.getenv("DATABASE_URL")) File "C:UsersAmber
BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyengine__init__.py",
line 424, in create_engine
return strategy.create(*args, **kwargs) File "C:UsersAmber BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyenginestrategies.py",
line 50, in create
u = url.make_url(name_or_url) File "C:UsersAmber BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyengineurl.py",
line 211, in make_url
return _parse_rfc1738_args(name_or_url) File "C:UsersAmber BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyengineurl.py",
line 270, in _parse_rfc1738_args
"Could not parse rfc1738 URL from string '%s'" % name) sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string
'C:Program FilesPostgreSQL10data'




Please someone help me resolving this issue.










share|improve this question





























    -3















    I am working on sqlalchemy and there's command in it engine -
    create_engine(os.getenv("DATABASE_URL")).



    When I run the program it shows an error saying -




    "Could not parse rfc1738 URL from string 'C:Program Files PostgreSQL10data"




    Code



    import os

    from sqlalchemy import create_engine
    from sqlalchemy.orm import scoped_session, sessionmaker

    #engine = create_engine('sqlite://')
    engine = create_engine(os.getenv("DATABASE_URL"))
    db = scoped_session(sessionmaker(bind=engine))

    def main():
    flights = db.execute("SELECT origin, destinaiton, duration FROM flights").fetchall()
    for flights in flights:
    print(f"{flight.origin} to {flight.destination}, {flight.duration} minutes.")

    if __name__ == "__main__":
    main()


    Error




    Traceback (most recent call last): File "list.py", line 7, in

    engine = create_engine(os.getenv("DATABASE_URL")) File "C:UsersAmber
    BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyengine__init__.py",
    line 424, in create_engine
    return strategy.create(*args, **kwargs) File "C:UsersAmber BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyenginestrategies.py",
    line 50, in create
    u = url.make_url(name_or_url) File "C:UsersAmber BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyengineurl.py",
    line 211, in make_url
    return _parse_rfc1738_args(name_or_url) File "C:UsersAmber BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyengineurl.py",
    line 270, in _parse_rfc1738_args
    "Could not parse rfc1738 URL from string '%s'" % name) sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string
    'C:Program FilesPostgreSQL10data'




    Please someone help me resolving this issue.










    share|improve this question



























      -3












      -3








      -3








      I am working on sqlalchemy and there's command in it engine -
      create_engine(os.getenv("DATABASE_URL")).



      When I run the program it shows an error saying -




      "Could not parse rfc1738 URL from string 'C:Program Files PostgreSQL10data"




      Code



      import os

      from sqlalchemy import create_engine
      from sqlalchemy.orm import scoped_session, sessionmaker

      #engine = create_engine('sqlite://')
      engine = create_engine(os.getenv("DATABASE_URL"))
      db = scoped_session(sessionmaker(bind=engine))

      def main():
      flights = db.execute("SELECT origin, destinaiton, duration FROM flights").fetchall()
      for flights in flights:
      print(f"{flight.origin} to {flight.destination}, {flight.duration} minutes.")

      if __name__ == "__main__":
      main()


      Error




      Traceback (most recent call last): File "list.py", line 7, in

      engine = create_engine(os.getenv("DATABASE_URL")) File "C:UsersAmber
      BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyengine__init__.py",
      line 424, in create_engine
      return strategy.create(*args, **kwargs) File "C:UsersAmber BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyenginestrategies.py",
      line 50, in create
      u = url.make_url(name_or_url) File "C:UsersAmber BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyengineurl.py",
      line 211, in make_url
      return _parse_rfc1738_args(name_or_url) File "C:UsersAmber BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyengineurl.py",
      line 270, in _parse_rfc1738_args
      "Could not parse rfc1738 URL from string '%s'" % name) sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string
      'C:Program FilesPostgreSQL10data'




      Please someone help me resolving this issue.










      share|improve this question
















      I am working on sqlalchemy and there's command in it engine -
      create_engine(os.getenv("DATABASE_URL")).



      When I run the program it shows an error saying -




      "Could not parse rfc1738 URL from string 'C:Program Files PostgreSQL10data"




      Code



      import os

      from sqlalchemy import create_engine
      from sqlalchemy.orm import scoped_session, sessionmaker

      #engine = create_engine('sqlite://')
      engine = create_engine(os.getenv("DATABASE_URL"))
      db = scoped_session(sessionmaker(bind=engine))

      def main():
      flights = db.execute("SELECT origin, destinaiton, duration FROM flights").fetchall()
      for flights in flights:
      print(f"{flight.origin} to {flight.destination}, {flight.duration} minutes.")

      if __name__ == "__main__":
      main()


      Error




      Traceback (most recent call last): File "list.py", line 7, in

      engine = create_engine(os.getenv("DATABASE_URL")) File "C:UsersAmber
      BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyengine__init__.py",
      line 424, in create_engine
      return strategy.create(*args, **kwargs) File "C:UsersAmber BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyenginestrategies.py",
      line 50, in create
      u = url.make_url(name_or_url) File "C:UsersAmber BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyengineurl.py",
      line 211, in make_url
      return _parse_rfc1738_args(name_or_url) File "C:UsersAmber BhanarkarAppDataLocalProgramsPythonPython36libsite-packagessqlalchemyengineurl.py",
      line 270, in _parse_rfc1738_args
      "Could not parse rfc1738 URL from string '%s'" % name) sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string
      'C:Program FilesPostgreSQL10data'




      Please someone help me resolving this issue.







      flask sqlalchemy






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 18 '18 at 5:26







      Amber Bhanarkar

















      asked Jul 18 '18 at 5:11









      Amber BhanarkarAmber Bhanarkar

      11




      11
























          2 Answers
          2






          active

          oldest

          votes


















          1














          The engine URL shouldn't be a path to your local Postgres installation but a sting that tells SQLAlchemy how to connect to the database. It has the following format:



          postgresql://username:password@server:port/databasename





          share|improve this answer


























          • Using the above statement I get an error saying - AttributeError: 'NoneType' object has no attribute '_instantiate_plugins'

            – Amber Bhanarkar
            Jul 18 '18 at 6:06



















          0














          I'm also watching course video of cs50 now. You should try to just use create_engine("your_database_url").



          If you still want to use create_engine(os.getenv("DATABASE_URL")) tp process, make sure you can log in using the command line like this psql $DATABASE_URL.






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51393994%2fsqlalchemy-showing-an-error-related-to-os-getenv%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            The engine URL shouldn't be a path to your local Postgres installation but a sting that tells SQLAlchemy how to connect to the database. It has the following format:



            postgresql://username:password@server:port/databasename





            share|improve this answer


























            • Using the above statement I get an error saying - AttributeError: 'NoneType' object has no attribute '_instantiate_plugins'

              – Amber Bhanarkar
              Jul 18 '18 at 6:06
















            1














            The engine URL shouldn't be a path to your local Postgres installation but a sting that tells SQLAlchemy how to connect to the database. It has the following format:



            postgresql://username:password@server:port/databasename





            share|improve this answer


























            • Using the above statement I get an error saying - AttributeError: 'NoneType' object has no attribute '_instantiate_plugins'

              – Amber Bhanarkar
              Jul 18 '18 at 6:06














            1












            1








            1







            The engine URL shouldn't be a path to your local Postgres installation but a sting that tells SQLAlchemy how to connect to the database. It has the following format:



            postgresql://username:password@server:port/databasename





            share|improve this answer















            The engine URL shouldn't be a path to your local Postgres installation but a sting that tells SQLAlchemy how to connect to the database. It has the following format:



            postgresql://username:password@server:port/databasename






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 21 '18 at 3:58

























            answered Jul 18 '18 at 5:27









            MureinikMureinik

            181k22131200




            181k22131200













            • Using the above statement I get an error saying - AttributeError: 'NoneType' object has no attribute '_instantiate_plugins'

              – Amber Bhanarkar
              Jul 18 '18 at 6:06



















            • Using the above statement I get an error saying - AttributeError: 'NoneType' object has no attribute '_instantiate_plugins'

              – Amber Bhanarkar
              Jul 18 '18 at 6:06

















            Using the above statement I get an error saying - AttributeError: 'NoneType' object has no attribute '_instantiate_plugins'

            – Amber Bhanarkar
            Jul 18 '18 at 6:06





            Using the above statement I get an error saying - AttributeError: 'NoneType' object has no attribute '_instantiate_plugins'

            – Amber Bhanarkar
            Jul 18 '18 at 6:06













            0














            I'm also watching course video of cs50 now. You should try to just use create_engine("your_database_url").



            If you still want to use create_engine(os.getenv("DATABASE_URL")) tp process, make sure you can log in using the command line like this psql $DATABASE_URL.






            share|improve this answer






























              0














              I'm also watching course video of cs50 now. You should try to just use create_engine("your_database_url").



              If you still want to use create_engine(os.getenv("DATABASE_URL")) tp process, make sure you can log in using the command line like this psql $DATABASE_URL.






              share|improve this answer




























                0












                0








                0







                I'm also watching course video of cs50 now. You should try to just use create_engine("your_database_url").



                If you still want to use create_engine(os.getenv("DATABASE_URL")) tp process, make sure you can log in using the command line like this psql $DATABASE_URL.






                share|improve this answer















                I'm also watching course video of cs50 now. You should try to just use create_engine("your_database_url").



                If you still want to use create_engine(os.getenv("DATABASE_URL")) tp process, make sure you can log in using the command line like this psql $DATABASE_URL.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 21 '18 at 9:52









                Ivan Aracki

                1,68142540




                1,68142540










                answered Nov 20 '18 at 21:48









                Radar LeiRadar Lei

                11




                11






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51393994%2fsqlalchemy-showing-an-error-related-to-os-getenv%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                    Alcedinidae

                    RAC Tourist Trophy