When you create table class using flask_sqlalchemy (the Flask extension for SQLAlchemy), it can maps the modal class to a proper table automatically. This is cool but if you have a table name with underscore (e.g. MY_SAMPLE_TABLE) and you name your model class with the underscore ('_') as usual, you will find SQLAlchemy will map your table name as something the following:
"MY__SAMPLE__TABLE"
Each single underscore (_) with becomes a double underscores (__). This is annoying and you might believe this is a bug, but in fact you can resolve this issues by naming your table class using the PEP8 naming convention, and named your class as:
class MySampleTable(db.Model):
field_id = db.Column(db.Integer, primary_key = True)
field_data = db.Column(db.String(200))
The the SQLAlchemy will map the MySampleTable class to table name as "MY_SAMPLE_TABLE" correctly.
For more information about PEP8, click here for details.
Subscribe to:
Post Comments (Atom)
CSP on Apache
To add CSP to root if sort of funny. The following will NOT work for most cases !! <LocationMatch "^/$"> Header s...
-
When Office2003 couldn't find file SKU011.CAB: regedit -> [HKEY_LOCAL_MACHINE] -> [SOFTWARE] -> [Microsoft] -> [Office] -...
-
The resolution can be changed by editing the BlueStack's registry: HKLM\SOFTWARE\BlueStacks\Guests\Android\FrameBuffer\0\Height and ...
-
Suppose you got a file in Big5 containing some HKSCS characters (e.g. 深水埗, 赤鱲角, etc). When your environment (Ref: Charset.defaultCharset( ) ...
No comments:
Post a Comment