question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

column names are stripped their '_id' part

See original GitHub issue

It seems that when a column is named, say “table_id”, the generated models is always “table”.

Command used: python -m pwiz -e mysql -u root database >> models.py

edit: I observe the same behavior with names such as “app-id”

e.g.:

sql schema: DROP TABLE IF EXISTS Application; /!40101 SET @saved_cs_client = @@character_set_client */; /!40101 SET character_set_client = utf8 /; CREATE TABLE Application ( id int(11) NOT NULL AUTO_INCREMENT, app_id char(100) NOT NULL, app_name char(100) NOT NULL, app_env text, app_submit text NOT NULL, app_dag text, app_master char(100) NOT NULL, app_driver int(11) DEFAULT NULL, PRIMARY KEY (id), KEY app_driver (app_driver), CONSTRAINT Application_ibfk_1 FOREIGN KEY (app_driver) REFERENCES Container (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /!40101 SET character_set_client = @saved_cs_client */;

class Application(BaseModel): app_dag = TextField(null=True) app_driver = ForeignKeyField(db_column=‘app_driver’, null=True, rel_model=Container, to_field=‘id’) app_env = TextField(null=True) app = CharField(db_column=‘app_id’) app_master = CharField() app_name = CharField() app_submit = TextField()

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
ghostcommented, Mar 7, 2018

Is there any way to keep “_id” exist?

3reactions
coleifercommented, Mar 8, 2018

You can name your fields whatever you want, just specify the actual column name using the column_name parameter:


class MyModel(Model):
    some_field = TextField(column_name='actual_column_name')
    another_field = IntegerField(column_name='another_field_id')
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to retain column headers of data frame after Pre ...
Now when I do this on this data frame it will strip the column headers. from sklearn import preprocessing X_imputed=preprocessing.Imputer().
Read more >
Problem with removing part of string while using join
RESOURCENAME but stripped from the domain part in the string. SELECT; res.RESOURCEID 'Resource ID', ...
Read more >
pandas.wide_to_long — pandas 1.5.2 documentation
A character indicating the separation of the variable names in the wide format, to be stripped from the names in the long format....
Read more >
Nest and unnest - tidyr - Tidyverse
In nest() , the new inner names will have the outer names + names_sep automatically stripped. This makes names_sep roughly symmetric between nesting...
Read more >
How to Name Matrix Rows and Columns in R programming
R stores the row and column names in an attribute called dimnames. Use the dimnames() function to extract or set those values. Using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found