-
Notifications
You must be signed in to change notification settings - Fork 604
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
csvsql: agate-sql: Add option to set varchar length to data's maximum length, or to a user-provided length #928
Comments
Different databases have different default behavior in agate-sql (which csvsql uses) - it seems mssql defaults to max. We can add a flag to csvsql to calculate the max length from the data. Some users don't want this, because they may add new data whose fields are longer, or they may not want csvsql to do any inference on the data (which can be slow for large files). |
@jpmckinney Thanks for reviewing the request. regards |
I'm interested in something like this for Oracle also. Another option would be to set a default for varchar on the command line like varchar2(1000). Thanks |
I really thought csvsql used to do this already, at least for postgres. Finding max lengths for values in multiple columns and setting reasonable varchar limits is a pain, would really this to be automated |
Why do you need limits when using Postgres? The current behavior with Postgres is to set no limit. |
Postgres describes no performance concern, so the only reason I can imagine is database-level data validation - though validation is often better handled in code. https://www.postgresql.org/docs/current/datatype-character.html |
@jpmckinney yes, it's for data validation, it's saved me more than once from erroneous data being inserted in wrong/mismatched columns |
Hi, any progress on this? I am struggling with csvsql creating smaller fields than needed, instead of just using varchar at full length... |
@acosonic What database are you using? Its behavior differs across databases. FWIW, most people here are discussing csvsql creating fields that are longer (maximum length) than needed – in MSSQL, PostgreSQL and also sounds like Oracle. |
Mysql, it works well, on most csv files. |
Hi
Not sure if I am not passing the right flags, I noticed that the column sizes in the create table query default to max e.g. varchar (max) . Is there an option so that column sizes are inferred based on the actual data.
The text was updated successfully, but these errors were encountered: