csvsql: is it possible to use a csvsql sql statement output to create a table (inferencing related)
See original GitHub issueHi,
sometimes the field inferencing does not work properly. An example I have is a field with this kind of value - 085232
- that becomes DECIMAL(38, 0)
and it’s converted to 85232.
Then I modify
CREATE TABLE mytable (
fieldone VARCHAR(27) NOT NULL,
`MYFIELD` DECIMAL(38, 0) NOT NULL,
);
to
CREATE TABLE mytable (
fieldone VARCHAR(27) NOT NULL,
`MYFIELD` VARCHAR(6) NOT NULL,
);
For me it would be great to use csvsql to create a first version of sql statement, to edit it, and then to have have the opportunity to run something like:
# create the table if not exist
csvsql --db "mysql+pymysql://user:password@localhost/test" --create-if-not-exists --statement mystatement.sql
# insert the data in the table
csvsql --db "mysql+pymysql://user:password@localhost/test" --tables mytable --insert --overwrite --create-if-not-exists myfile.csv
Is there a way, using csvkit, to use a sql statement to create a table?
Thank you
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
csvsql — csvkit 1.0.7 documentation - Read the Docs
Generate SQL statements for a CSV file or execute those statements directly on a database. In the latter case supports both creating tables...
Read more >csvsql: Generate statements without actually running them ...
I'd like to be able to take a CSV and generate the CREATE TABLE and INSERT statements for it without actually running them...
Read more >CREATE TABLE AS - Amazon Redshift
The new table is loaded with data defined by the query in the command. The table columns have names and data types associated...
Read more >csvkit - Read the Docs
csvsql --query "select name from data where age > 30" data.csv > new.csv ... You can also use csvsql to create the table...
Read more >Flat files - DSSG Hitchhickers guide
This summer, you will use a database to store and analyze data. ... Schema: similar to a folder. ... csvsql generates create table...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
What would the content of
mystatement.sql
be?Ah, okay. To keep the maintenance burden low, we recommend using tools that are already installed, wherever possible. That way, csvkit is focused on unique features. So, I’ll close.