sqlalchemy / sqlalchemy/alembic

Documentation Notes On "Building an Up to Date Database from Scratch"

Open
#683 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
Python
Stars
4.4k
Forks
375
PR merge metrics
No merged PRs in 30d

Description

My goal was simple enough:

  • Extract ~40+ table MySQL schema via SQLAlchemy.inspect (done, but the scipt's as rough as you'd expect) to a vanilla models.py
  • Write unit tests against SQLite and Alembic
  • Delploy to a production MySQL with another migration to handle things like FULLTEXT indices.

Challenges encountered:

  • Using the stamp() operation with the models.py and "head" gave me a headache (heh).
  • I really needed to prepare a 0th revision and then use that revision number in stamp().
  • Then I could prepare another 1st revision and use bulk_insert().
  • But to get bulk_insert() to work, I had to say, in my revision script. . .

from models import SomeTable
. . .
op.bulk_insert(SomeTable.__table__,[{row_dict0},{row_dict1}...])

Summary: I am very grateful for this tool and hope someday to contribute documentation of better quality than this ransom note.
Cheers!

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 by reviewing the described SQLAlchemy.inspect workflow, models.py, and the Alembic stamp(), bulk_insert(), and revision steps. No documentation file or test is named; done would require turning these database-migration notes into a clear, reproducible guide covering SQLite testing and production MySQL deployment.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, python, sqlalchemy, sqlite
Domain
databases, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.