Skip to content

Conversation

julesyan
Copy link
Member

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

@julesyan julesyan linked an issue Aug 27, 2025 that may be closed by this pull request
@forstie
Copy link
Collaborator

forstie commented Aug 27, 2025

Looking at the code is aok, but trying the function is better.
Can I please get a vsix?

@julesyan
Copy link
Member Author

@forstie
Copy link
Collaborator

forstie commented Aug 27, 2025

Thanks!
Where do I find the new "Generate Insert from File". action?

image

Copy link
Member

@worksofliam worksofliam left a 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.

@forstie
Copy link
Collaborator

forstie commented Aug 27, 2025

Apollo 2 - Jujne 18.csv

@forstie
Copy link
Collaborator

forstie commented Aug 27, 2025

If the spreadsheet does not include the column names as the first row, the generated INSERT won't work.
Is there a way to handle this situation or does this need to be pointed out in the documentation?
image

@julesyan
Copy link
Member Author

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
vscode-db2i-1.14.0.vsix 2.zip

@forstie
Copy link
Collaborator

forstie commented Aug 27, 2025

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.

@julesyan
Copy link
Member Author

vscode-db2i-1.14.0.vsix 3.zip

@forstie based on our discussion i now prompt the user if the csv has headers or not, it will generate based on that answer

@julesyan julesyan requested a review from worksofliam August 27, 2025 17:33
@julesyan
Copy link
Member Author

vscode-db2i-1.14.0.vsix.zip
Changed it so any file will show the right click menu. If the file is not csv or json it will prompt the user

@julesyan
Copy link
Member Author

vscode-db2i-1.14.0.vsix.zip

Allowed column names to contain spaces

Copy link
Collaborator

@forstie forstie left a 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.

Copy link
Member

@SanjulaGanepola SanjulaGanepola left a 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:

image

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;

@julesyan
Copy link
Member Author

Copy link
Member

@SanjulaGanepola SanjulaGanepola left a 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

Copy link
Member

@SanjulaGanepola SanjulaGanepola left a 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

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

Successfully merging this pull request may close these issues.

Feature: Import data
4 participants