Note that there are some explanatory texts on larger screens.

plurals
  1. POLOAD DATA INFILE doesn't load all my data
    primarykey
    data
    text
    <p>I have 1048 rows of csv data I need to read in. The data looks like this:</p> <pre><code>\N,Olenevka,Оленевка,2596 \N,Urzuf,Урзуф,2904 \N,Lebedyn,ЛЕБЕДИН,27695 \N,Staryy Dobrotvor,Staryy Dobrotvor,6436 </code></pre> <p>Here is the table:</p> <pre><code>+------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+------------------+------+-----+---------+----------------+ | city_id | int(10) unsigned | NO | PRI | NULL | auto_increment | | name | text | YES | | NULL | | | alt_name | text | YES | | NULL | | | population | int(10) unsigned | NO | | NULL | | +------------+------------------+------+-----+---------+----------------+ </code></pre> <p>Here is the code:</p> <pre><code>db.query(""" LOAD DATA INFILE '%s' INTO TABLE %s CHARACTER SET utf8 FIELDS TERMINATED BY ',' (@skip, name, alt_name, population) """ % (temp_file, table)) class Database(object): def __init__(self, database): self.database = database def query(self, cmd): return subprocess.call(['mysql -u root -e "%s" %s' % (cmd, self.database)], shell=True) </code></pre> <p>When I issue the command from python, it only reads in 1025 rows. But if I issue the same command from a mysql prompt, I get them all.</p> <p>Here is the last rows from a SELECT * after running the code:</p> <pre><code>| 1023 | Alchevs’k | Алчевск | 116000 | | 1024 | Yakymivka | Якимівка | 12353 | | 1025 | Okhtyrka | Охтирка | 49818 | | 1026 | Adzhamka | А | 0 | +---------+------------------+-------------------------------------+------------+ </code></pre> <p>The last line is only partly read. Here is the rest of the file.</p> <pre><code>\N,Okhtyrka,Охтирка,49818 \N,Adzhamka,Аджамка,3859 \N,Malynivka,Малинівка,7502 \N,Mykhaylivka,Mykhaylivka,3352 \N,Kopashnovo,Копашново,3010 \N,Narkevychi,Наркевичі,1631 \N,Kirove,Кірове,3291 \N,Orikhove,Оріхове,3000 \N,Krasni Okny,Красні Окни,5461 \N,Pavlivka,Pavlovka,738 \N,Kuchurhan,Кучурган,3183 \N,Smyga,Смыга,2800 \N,Tayirove,Таїрове,1849 \N,Teplodar,Теплодар,8502 \N,Komsomolsk,Комсомольськ,51740 \N,Славутич,Славутич,25000 \N,Розгирче,Розгирче,566 \N,Orzhiv,Оржів,4125 \N,Shkil’ne,Шкільне,2127 \N,Denyshi,Деныши,1164 \N,Chetfalva,Четфалва,755 \N,Stepove,Степовое,1549 \N,Scholkine,,11677 \N,Yuzhnoukrains'k,Южноукраїнськ,39430 </code></pre> <p>Ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload