-
Notifications
You must be signed in to change notification settings - Fork 37
Create INSERT statement based on imported csv or json #435
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
base: main
Are you sure you want to change the base?
Conversation
Looking at the code is aok, but trying the function is better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be nice to have a right click or an editor button (similar to the run button) for this new command.
Since we can't tell if the first column is headers without asking (which we could do if we want), i would say add it to the documentation for csv files. Otherwise we will have to put in dummy columns |
If we could detect that the 1st row wasn't simple names, we could generate an INSERT with VALUES statement that simply avoided the column names syntax part. That piece is optional but would infer that the spreadsheet was generated by a SELECT * FROM xyz type of query. |
@forstie based on our discussion i now prompt the user if the csv has headers or not, it will generate based on that answer |
…ype is extension is not expected
vscode-db2i-1.14.0.vsix.zip |
Allowed column names to contain spaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes.
Everything is looking great now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed an issue when importing from JSON data (also reproducible with CSV too) when the data has quotes:

You can reproduce this by importing the generated data from running:
json: select * from sample.employee;
You can compare with what the expected result should be using:
sql: select * from sample.employee;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment, everything else looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Nice work
The command is "Generate Insert from File". Tested with the attached files, including with blanks. Will open a new file with the newly generated insert statement.
Closes issue #169
export.csv
export.json