Skip to content

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