converting true false string to boolean while using "load infile data"
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Luau
--
Chapters
00:00 Question
01:43 Accepted answer (Score 7)
03:23 Thank you
--
Full question
https://stackoverflow.com/questions/1762...
Accepted answer links:
[LOAD DATA INFILE]: http://dev.mysql.com/doc/en/load-data.ht...
[LOAD DATA INFILE]: http://dev.mysql.com/doc/en/load-data.ht...
--
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'.