Skip to content

Add the ability to run actions right after connecting to the database#1373

Open
hayssams wants to merge 3 commits intoMause:mainfrom
starlake-ai:feature/pre_actions
Open

Add the ability to run actions right after connecting to the database#1373
hayssams wants to merge 3 commits intoMause:mainfrom
starlake-ai:feature/pre_actions

Conversation

@hayssams
Copy link

You can run arbitrary SQL commands right after connecting by passing a list of SQL commands to the pre_actions parameter in connect_args

from sqlalchemy import create_engine
create_engine(
    'duckdb:///:memory:',
    connect_args={
        'pre_actions': [
            "ATTACH 'file.db' AS file_db';",
            "SET some_config_option='some_value';"
        ]
    }
)

@tiboun
Copy link

tiboun commented Nov 12, 2025

This would be a really useful addition — being able to run SQL commands on connection opening makes it much easier to set consistent session parameters across connections.

Would love to see this reviewed and merged when possible 🙌

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

Successfully merging this pull request may close these issues.

2 participants