wireservice / agate-sql

agate-sql adds SQL read/write support to agate.
https://agate-sql.readthedocs.io
MIT License
18 stars 15 forks source link

Table.to_sql col_len_multiplier and min_col_len parameters added. #30

Closed RogerWebb closed 5 years ago

RogerWebb commented 6 years ago

Two parameters have been added to Table.to_sql and Table.make_sql_table to allow for larger column widths than what is present in the sheet used to create the table. This will allow for subsequent runs where field values may exceed the max from the initial sheet without truncating the value in the database. The "col_len_multiplier" is multiplied against the max length when creating the table. Default is 1 and this should not change current behavior. The "min_col_len" can be used alone or in conjunction with the multiplier to ensure that, no matter what, VARCHAR columns will not be less than this value. Default is 1 an leaves the zero-length checking behavior unchanged.

Tests were added for the new fields. All existing tests pass unchanged.

RogerWebb commented 6 years ago

I was hoping to hear from someone if you had a chance. If this looks good, and you're interested in accepting contributions, I've got more in mind.

jpmckinney commented 5 years ago

@RogerWebb Sorry for the delay – I hadn't been watching this repo, and there isn't much traffic on it.

I've merged your changes and added you to AUTHORS.rst – thanks!

I'm now watching this repo in case you have other contributions to make.