converting true false string to boolean while using "load infile data"
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Light Drops
--
Chapters
00:00 Converting True False String To Boolean While Using &Quot;Load Infile Data&Quot;
01:23 Accepted Answer Score 7
02:31 Thank you
--
Full question
https://stackoverflow.com/questions/1762...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #mysql #sqlserver #mysqlpython
#avk47
ACCEPTED ANSWER
Score 7
As documented under LOAD DATA INFILE Syntax:
By default, when no column list is provided at the end of the
LOAD DATA INFILEstatement, input lines are expected to contain a field for each table column. If you want to load only some of a table's columns, specify a column list:LOAD DATA INFILE 'persondata.txt' INTO TABLE persondata (col1,col2,...);You must also specify a column list if the order of the fields in the input file differs from the order of the columns in the table. Otherwise, MySQL cannot tell how to match input fields with table columns.
The column list can contain either column names or user variables. With user variables, the
SETclause enables you to perform transformations on their values before assigning the result to columns.User variables in the
SETclause can be used in several ways. The following example uses the first input column directly for the value oft1.column1, and assigns the second input column to a user variable that is subjected to a division operation before being used for the value oft1.column2:LOAD DATA INFILE 'file.txt' INTO TABLE t1 (column1, @var1) SET column2 = @var1/100;
In your case you could do something like SET boolean_column := @dummy_variable = 'True'.