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

SQL block could use some love to be prod ready #3

Open
iantbutler01 opened this issue Aug 10, 2024 · 1 comment
Open

SQL block could use some love to be prod ready #3

iantbutler01 opened this issue Aug 10, 2024 · 1 comment

Comments

@iantbutler01
Copy link
Contributor

@kallsyms we can talk about some ways to shore this up when we sync next

  • Connections are not pooled by default
  • Cursor should probably use RealDictCursor
  • Provide some context managed niceties around checking out a connection from a pool, e.g.
    @contextlib.contextmanager
    def get_connection(self):
        conn = self.connection_pool.getconn()
        try:
            yield conn
        finally:
            self.connection_pool.putconn(conn)

    @contextlib.contextmanager
    def get_cursor(self):
        with self.get_connection() as conn:
            cursor = conn.cursor(cursor_factory=RealDictCursor)
            try:
                yield cursor
            finally:
                conn.commit()
                cursor.close()
@iantbutler01
Copy link
Contributor Author

My only thing is how these changes would interact with say SQLAlchemy if someone wants to use our stuff there

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

1 participant