tortoise / tortoise/tortoise-orm

AttributeError: 'NoneType' object has no attribute 'acquire'

Open
#1,035 0 comments 0 reactions 0 assignees View on GitHub

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

image

But I do this

image

It can perfectly solve the switching mode, but I need to use SQL. Can I use tortoise statements

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.