-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safely saving pandas DataFrame to SQL table via Django #125
Comments
@pandichef this is cool! But how do we cover the case when we create the the pandas dataframe based on a join (related field) |
In my use case, I have a single foreign key called df['pool_id'] = 9 If you want to handle choices fields or foreign key fields more formally, I think it can be done. For model choices, you just need to check that the value is valid or throw an exception. For foreign keys, I'd add a boolean parameter to |
This is an amazing code. Thanks a lot as it helped me with a project. |
How can we add some logic to avoid duplicate entries for the incoming data. For example I am able to save the excel file in my database using to_sql. I have to validate that no two duplicate entries can be created for a column in this case I have title column and validate if two products have same title or name, the entry does not get added to the database. |
This works wonders, thank you for posting! |
I recently wrote the following for a project, but
django-pandas
actually seems like a better home for it. The idea is basically to implementto_sql
via the Django ORM to get all the validation goodness of the ORM. (A related feature would be another set of tools to validate that a DataFrame is consistent with the Django model schema. That is the 2nd example below)Is anyone here interested in a PR for this?
The text was updated successfully, but these errors were encountered: