Jupyter Python with SQLite gives me “database or disk is full” error



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have created an SQLite database with billions of rows imported (currently standing at 1.1 TB) from CSV files into various tables in the database. One such table (X) contains more than 50 GB worth of data. I am using Jupyter Python (in my own conda environment) to fetch results for a query to this table. The table has various years of data based on a time column, so I can also use conditions (in the where clause) to fetch only yearly data or monthly data.



Indexing is done on this table using primary keys which was used when creating the table.



I am using pandas to query the DB and fetch results:



pd.read_sql_query("select id, strftime("%Y-%m", time) as month,
count(case value when '1' then 1 else null end) as values_count from X where time>= '2018-01-01' GROUP BY id, strftime("%Y-%m", time);", conn)



In the above query I am trying to group all IDs based on months only for the year 2018 (considering I do not have data for future years) and count the values when they are equal to 1.



I am consistently getting a DatabaseError: database or disk is full error.



The specs are:



  • SQLite3 version: 3.25.2

  • Python version (on Jupyter environment):
    3.7.0

  • Linux memory: 295 GB

I am pretty sure that I will be able to parse and generate the SQL output using the memory I have available (as another query on the same DB works), but I am not sure if Python uses memory or a temp directory to generate the result. The query also terminates after almost 30 minutes (using almost 100% CPU).



I also looked at using chunksize for read_sql_query but it seems that this is useful after the query has executed successfully. Can anyone shed more light into how I can make this work?










share|improve this question






















  • Also, sometimes when I observe the memory utilization using htop, I don't see the Mem usage go up, it stays at a constant.

    – Rg90
    Nov 15 '18 at 17:40

















0















I have created an SQLite database with billions of rows imported (currently standing at 1.1 TB) from CSV files into various tables in the database. One such table (X) contains more than 50 GB worth of data. I am using Jupyter Python (in my own conda environment) to fetch results for a query to this table. The table has various years of data based on a time column, so I can also use conditions (in the where clause) to fetch only yearly data or monthly data.



Indexing is done on this table using primary keys which was used when creating the table.



I am using pandas to query the DB and fetch results:



pd.read_sql_query("select id, strftime("%Y-%m", time) as month,
count(case value when '1' then 1 else null end) as values_count from X where time>= '2018-01-01' GROUP BY id, strftime("%Y-%m", time);", conn)



In the above query I am trying to group all IDs based on months only for the year 2018 (considering I do not have data for future years) and count the values when they are equal to 1.



I am consistently getting a DatabaseError: database or disk is full error.



The specs are:



  • SQLite3 version: 3.25.2

  • Python version (on Jupyter environment):
    3.7.0

  • Linux memory: 295 GB

I am pretty sure that I will be able to parse and generate the SQL output using the memory I have available (as another query on the same DB works), but I am not sure if Python uses memory or a temp directory to generate the result. The query also terminates after almost 30 minutes (using almost 100% CPU).



I also looked at using chunksize for read_sql_query but it seems that this is useful after the query has executed successfully. Can anyone shed more light into how I can make this work?










share|improve this question






















  • Also, sometimes when I observe the memory utilization using htop, I don't see the Mem usage go up, it stays at a constant.

    – Rg90
    Nov 15 '18 at 17:40













0












0








0








I have created an SQLite database with billions of rows imported (currently standing at 1.1 TB) from CSV files into various tables in the database. One such table (X) contains more than 50 GB worth of data. I am using Jupyter Python (in my own conda environment) to fetch results for a query to this table. The table has various years of data based on a time column, so I can also use conditions (in the where clause) to fetch only yearly data or monthly data.



Indexing is done on this table using primary keys which was used when creating the table.



I am using pandas to query the DB and fetch results:



pd.read_sql_query("select id, strftime("%Y-%m", time) as month,
count(case value when '1' then 1 else null end) as values_count from X where time>= '2018-01-01' GROUP BY id, strftime("%Y-%m", time);", conn)



In the above query I am trying to group all IDs based on months only for the year 2018 (considering I do not have data for future years) and count the values when they are equal to 1.



I am consistently getting a DatabaseError: database or disk is full error.



The specs are:



  • SQLite3 version: 3.25.2

  • Python version (on Jupyter environment):
    3.7.0

  • Linux memory: 295 GB

I am pretty sure that I will be able to parse and generate the SQL output using the memory I have available (as another query on the same DB works), but I am not sure if Python uses memory or a temp directory to generate the result. The query also terminates after almost 30 minutes (using almost 100% CPU).



I also looked at using chunksize for read_sql_query but it seems that this is useful after the query has executed successfully. Can anyone shed more light into how I can make this work?










share|improve this question














I have created an SQLite database with billions of rows imported (currently standing at 1.1 TB) from CSV files into various tables in the database. One such table (X) contains more than 50 GB worth of data. I am using Jupyter Python (in my own conda environment) to fetch results for a query to this table. The table has various years of data based on a time column, so I can also use conditions (in the where clause) to fetch only yearly data or monthly data.



Indexing is done on this table using primary keys which was used when creating the table.



I am using pandas to query the DB and fetch results:



pd.read_sql_query("select id, strftime("%Y-%m", time) as month,
count(case value when '1' then 1 else null end) as values_count from X where time>= '2018-01-01' GROUP BY id, strftime("%Y-%m", time);", conn)



In the above query I am trying to group all IDs based on months only for the year 2018 (considering I do not have data for future years) and count the values when they are equal to 1.



I am consistently getting a DatabaseError: database or disk is full error.



The specs are:



  • SQLite3 version: 3.25.2

  • Python version (on Jupyter environment):
    3.7.0

  • Linux memory: 295 GB

I am pretty sure that I will be able to parse and generate the SQL output using the memory I have available (as another query on the same DB works), but I am not sure if Python uses memory or a temp directory to generate the result. The query also terminates after almost 30 minutes (using almost 100% CPU).



I also looked at using chunksize for read_sql_query but it seems that this is useful after the query has executed successfully. Can anyone shed more light into how I can make this work?







python linux pandas sqlite jupyter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 16:05









Rg90Rg90

3263827




3263827












  • Also, sometimes when I observe the memory utilization using htop, I don't see the Mem usage go up, it stays at a constant.

    – Rg90
    Nov 15 '18 at 17:40

















  • Also, sometimes when I observe the memory utilization using htop, I don't see the Mem usage go up, it stays at a constant.

    – Rg90
    Nov 15 '18 at 17:40
















Also, sometimes when I observe the memory utilization using htop, I don't see the Mem usage go up, it stays at a constant.

– Rg90
Nov 15 '18 at 17:40





Also, sometimes when I observe the memory utilization using htop, I don't see the Mem usage go up, it stays at a constant.

– Rg90
Nov 15 '18 at 17:40












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323421%2fjupyter-python-with-sqlite-gives-me-database-or-disk-is-full-error%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323421%2fjupyter-python-with-sqlite-gives-me-database-or-disk-is-full-error%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kleinkühnau

Makov (Slowakei)

Deutsches Schauspielhaus