tortoise / tortoise/tortoise-orm
AttributeError: 'NoneType' object has no attribute 'acquire'
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
I have this problem when switching schemas dynamically
def demo_conf_db_switch(db_base):
def func_work(func):
@functools.wraps(func)
async def wrapper(*args, **kwargs):
await Tortoise.init(db_base)
await Tortoise.generate_schemas()
data = await func(*args, **kwargs)
await Tortoise.close_connections()
return data
return wrapper
return func_work
db_base Is the link parameter I passed
There's this

But I do this

It can perfectly solve the switching mode, but I need to use SQL. Can I use tortoise statements
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the demo_conf_db_switch wrapper and the reported AttributeError involving acquire. Review how Tortoise.init, generate_schemas, and close_connections are used during dynamic schema or database switching. Done would require a confirmed explanation and a documented or tested way to perform the requested SQL-backed workflow, but no repository files or tests are named.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100