question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

csvsql: is it possible to use a csvsql sql statement output to create a table (inferencing related)

See original GitHub issue

Hi, 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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jpmckinneycommented, Mar 3, 2020

What would the content of mystatement.sql be?

0reactions
jpmckinneycommented, Mar 3, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found