tortoise / tortoise/tortoise-orm

MSSQLSchemaGenerator does not support creating tables in non-default (dbo) database schemas

Open
#1,531 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

Is your feature request related to a problem? Please describe.
I would like to use Tortoise to integrate with an existing application who's data is stored in MSSQL Server. However it makes use of multiple schemas (eg. control.table, sales.table) but tortoise can only map to dbo.*

Describe the solution you'd like
ideally there should be a META parameter db_schema that could be mapped into the templates something like this:

TABLE_CREATE_TEMPLATE = "CREATE TABLE [{db_schema}].[{table_name}] ({fields}){extra};"

Describe alternatives you've considered

Additional context

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 with MSSQLSchemaGenerator and its TABLE_CREATE_TEMPLATE, then trace how model META values are mapped into the template. Add support for a db_schema value so tables can target schemas such as control or sales instead of only dbo, and verify the generated CREATE TABLE statements.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sql
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.