Skip to content
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

Appending CSV file in existing table which has conflicting primary keys #74

Open
koslambrou opened this issue Nov 26, 2020 · 0 comments

Comments

@koslambrou
Copy link

koslambrou commented Nov 26, 2020

Suppose I have to following table named Test in a SQLite database:

Id Text
1
2
3
4 Four

Here's a CSV file which I want to append:

Id,Text
1,One
2,Two

I used the following command for the merge:

csvs-to-sqlite -t Test Test.csv sqlite.db

Here's the modified Test table:

Id Text
1  
2  
3  
4 Four
1 One
2 Two

As you can see, there are duplicate elements in the Id column (which is not a primary key)

Is there a way to get the following output ?

Id Text
1 One
2 Two
3
4 Four

If I declared the Id column as a primary key, appending to the table produces the error sqlite3.IntegrityError: UNIQUE constraint failed: Test.Id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant