PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, April 13, 2022

[FIXED] How to generate python models from existing Postgres schema?

 April 13, 2022     migration, postgresql, python, schema     No comments   

Issue

I have a PostgreSQL database with existing tables. I wish to :

  1. Create a set of Python models (plain classes, SQLAlchemy models or other) based on the existing database
  2. Then manage changes in these models with a migrations tool.

The second part I think is easy to achieve as long as I manage to get my initial schema created. How can this be achieved?


Solution

So if someone is willing to use SQLAlchemy I found these two solutions:

  1. Straight with SQLAlchemy reflection and automapping
  2. With sqlacodegen


Answered By - KZiovas
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing