question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wondering how db connection is established?

See original GitHub issue

Hey @frol , Great work on this prokect! A quick question regarding using a different db like: postgresql After I set postgres connection url, example api server doesn’t recognize it (I got some error, and search results suggest db is not connected). (it seems it only works with sqlite). I went on to try to find out why, I found this piece:

 def init_app(self, app):
      super(SQLAlchemy, self).init_app(app)                                                                                                                                                                                                                                                                                                          
      
      database_uri = app.config['SQLALCHEMY_DATABASE_URI']                                                                                                                      
      if database_uri and database_uri.startswith('sqlite:'):                                                                                                                  
            self.event.listens_for(engine.Engine, "connect")(set_sqlite_pragma)                                                                                                   
                                                                                                                                                                                   
      app.extensions['migrate'] = AlembicDatabaseMigrationConfig(self, compare_type=True)

in app/extensions/flask_sqlalchemy/__init__.py is doing the db initialization part. However, it is not using create_engine from sqlalchemy , and it is also not setting listening for posgresql db is provided in environment. So I conclude posgresql is not supported yet.

Maybe I am misunderstanding, can you comment on how postgresql is connected is in production mode ?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
frolcommented, Nov 1, 2017

I cannot access this postgresql from my local machine:

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection timed out
        Is the server running on host "whut2eat-api-postgresql-us-west-1.cxclxg5j1i7m.us-west-2.rds.amazonaws.com" (35.164.66.245) and accepting
        TCP/IP connections on port 5432?

psql client says the same thing, so it has nothing to do with SQLAlchemy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is Connection Pooling, and Why Should You Care
Database connection pooling is a way to reduce the cost of opening and closing connections by maintaining a “pool” of open connections that...
Read more >
How the database connection is built in the deployment
1 Answer 1 ... Simply you could use the server: localhost\sqlexpress in your connection string of your file app.config, assuming that you will ......
Read more >
Database Connections and Connection Pooling - YouTube
A database connection allows client software to talk to database server. A connection pool is a cache of database connections maintained so ...
Read more >
Database Connections: Less is More | by Wahome - Medium
A web server constantly sends out pieces of information to users in order to compose web pages. It constantly performs I/O operations to...
Read more >
Database connection - Wikipedia
A database connection is a facility in computer science that allows client software to talk to database server software, whether on the same...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found