marked stuff about sqlalchemy-codegen as outdated and moved it to bottom
This commit is contained in:
parent
56520fc72d
commit
e238700900
20
README.md
20
README.md
@ -74,15 +74,6 @@ some icons from heroicons.com
|
|||||||
|
|
||||||
## Other useful stuff
|
## Other useful stuff
|
||||||
|
|
||||||
### Generate SQLAlchemy code from an existing database
|
|
||||||
|
|
||||||
Right now the_works reflects an existing database in order to infer the underlying data models for SQLAlchemy. Of course, this only works if all the tables already exist in the database. If the_works is run with an empty database (this happens when running tests, for example), the app will create fresh tables in the database. The necessary information about the tables can be generated from an existing database with the help of [sqlacodegen](https://pypi.org/project/sqlacodegen/). Just run this command inside the project's root directory:
|
|
||||||
|
|
||||||
`sqlacodegen --generator tables sqlite:///path/to/good/db.sqlite > ./the_works/tables.py`
|
|
||||||
|
|
||||||
The tool sqlacodegen can also generate Python code declaring the data models directly. This would make the use of reflection obsolete. The command would be:
|
|
||||||
|
|
||||||
`sqlacodegen --generator declarative sqlite:///path/to/good/db.sqlite > outputfile.py`
|
|
||||||
|
|
||||||
|
|
||||||
### Export database schema
|
### Export database schema
|
||||||
@ -99,3 +90,14 @@ Method 2: Open DB in SQLitebrowser and use File -> Export -> Database to SQL fil
|
|||||||
### Generate `requirements.txt`
|
### Generate `requirements.txt`
|
||||||
|
|
||||||
I use [pipreqs](https://pypi.org/project/pipreqs/) to generate the file `requirements.txt`. The package scans all source files for import statements and uses those to extract all required Pip packages. See `pipreqs -h` for usage info.
|
I use [pipreqs](https://pypi.org/project/pipreqs/) to generate the file `requirements.txt`. The package scans all source files for import statements and uses those to extract all required Pip packages. See `pipreqs -h` for usage info.
|
||||||
|
|
||||||
|
|
||||||
|
### Outdated: Generate SQLAlchemy code from an existing database
|
||||||
|
|
||||||
|
~~Right now~~ In earlier stages, the_works reflects an existing database in order to infer the underlying data models for SQLAlchemy. Of course, this only works if all the tables already exist in the database. If the_works is run with an empty database (this happens when running tests, for example), the app will create fresh tables in the database. The necessary information about the tables can be generated from an existing database with the help of [sqlacodegen](https://pypi.org/project/sqlacodegen/). Just run this command inside the project's root directory:
|
||||||
|
|
||||||
|
`sqlacodegen --generator tables sqlite:///path/to/good/db.sqlite > ./the_works/tables.py`
|
||||||
|
|
||||||
|
The tool sqlacodegen can also generate Python code declaring the data models directly. This would make the use of reflection obsolete. The command would be:
|
||||||
|
|
||||||
|
`sqlacodegen --generator declarative sqlite:///path/to/good/db.sqlite > outputfile.py`
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user