Do not understand Error: binding parameter 0 - probably unsupported type












0















the following error occurs at line 13:



sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.



Comparing code on line 2 and code on line 13, line 2 works without out a problem and seems identical to line 13. What am I doing wrong?
date and tag are both strings.
date is for example "2018-11" and tag is something like "fare" and in my example it is always != "None".



if tag != "None":
self.c.execute("SELECT DISTINCT Date FROM financial_table WHERE strftime('%Y-%m', Date) = ? AND Tag = ? ORDER BY Date ", (date, tag)) #row 2
else:
self.c.execute("SELECT DISTINCT Date FROM financial_table WHERE strftime('%Y-%m', Date) = ? ORDER BY Date ", (date,))
single_dates = self.c.fetchall()
for i in single_dates:
print (i)

#take data in order to sum up all costs from one day
for i in single_dates:
print ("***",i)
if tag != "None":
self.c.execute("SELECT Price FROM financial_table WHERE Date = ? AND Tag = ?", (i, tag)) #line 13
else:
self.c.execute("SELECT Price FROM financial_table WHERE Date = ?", (i))
cache = self.c.fetchall()
print (cache)
self.plot_overall_price.append(sum(j for j, in cache)) #save overall price for
self.plot_date.append(i[0]) #a certain date
self.plot_date_days.append(i[0][8:10])


Thank you very much for your help!










share|improve this question




















  • 1





    Often when you query for a single column like you have in single_dates the results are returned as a list of tuples e.g., [('date',), ('date',),...]. Are you sure that i in your for loop is just a date string?

    – SuperShoot
    Nov 25 '18 at 11:22


















0















the following error occurs at line 13:



sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.



Comparing code on line 2 and code on line 13, line 2 works without out a problem and seems identical to line 13. What am I doing wrong?
date and tag are both strings.
date is for example "2018-11" and tag is something like "fare" and in my example it is always != "None".



if tag != "None":
self.c.execute("SELECT DISTINCT Date FROM financial_table WHERE strftime('%Y-%m', Date) = ? AND Tag = ? ORDER BY Date ", (date, tag)) #row 2
else:
self.c.execute("SELECT DISTINCT Date FROM financial_table WHERE strftime('%Y-%m', Date) = ? ORDER BY Date ", (date,))
single_dates = self.c.fetchall()
for i in single_dates:
print (i)

#take data in order to sum up all costs from one day
for i in single_dates:
print ("***",i)
if tag != "None":
self.c.execute("SELECT Price FROM financial_table WHERE Date = ? AND Tag = ?", (i, tag)) #line 13
else:
self.c.execute("SELECT Price FROM financial_table WHERE Date = ?", (i))
cache = self.c.fetchall()
print (cache)
self.plot_overall_price.append(sum(j for j, in cache)) #save overall price for
self.plot_date.append(i[0]) #a certain date
self.plot_date_days.append(i[0][8:10])


Thank you very much for your help!










share|improve this question




















  • 1





    Often when you query for a single column like you have in single_dates the results are returned as a list of tuples e.g., [('date',), ('date',),...]. Are you sure that i in your for loop is just a date string?

    – SuperShoot
    Nov 25 '18 at 11:22
















0












0








0








the following error occurs at line 13:



sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.



Comparing code on line 2 and code on line 13, line 2 works without out a problem and seems identical to line 13. What am I doing wrong?
date and tag are both strings.
date is for example "2018-11" and tag is something like "fare" and in my example it is always != "None".



if tag != "None":
self.c.execute("SELECT DISTINCT Date FROM financial_table WHERE strftime('%Y-%m', Date) = ? AND Tag = ? ORDER BY Date ", (date, tag)) #row 2
else:
self.c.execute("SELECT DISTINCT Date FROM financial_table WHERE strftime('%Y-%m', Date) = ? ORDER BY Date ", (date,))
single_dates = self.c.fetchall()
for i in single_dates:
print (i)

#take data in order to sum up all costs from one day
for i in single_dates:
print ("***",i)
if tag != "None":
self.c.execute("SELECT Price FROM financial_table WHERE Date = ? AND Tag = ?", (i, tag)) #line 13
else:
self.c.execute("SELECT Price FROM financial_table WHERE Date = ?", (i))
cache = self.c.fetchall()
print (cache)
self.plot_overall_price.append(sum(j for j, in cache)) #save overall price for
self.plot_date.append(i[0]) #a certain date
self.plot_date_days.append(i[0][8:10])


Thank you very much for your help!










share|improve this question
















the following error occurs at line 13:



sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.



Comparing code on line 2 and code on line 13, line 2 works without out a problem and seems identical to line 13. What am I doing wrong?
date and tag are both strings.
date is for example "2018-11" and tag is something like "fare" and in my example it is always != "None".



if tag != "None":
self.c.execute("SELECT DISTINCT Date FROM financial_table WHERE strftime('%Y-%m', Date) = ? AND Tag = ? ORDER BY Date ", (date, tag)) #row 2
else:
self.c.execute("SELECT DISTINCT Date FROM financial_table WHERE strftime('%Y-%m', Date) = ? ORDER BY Date ", (date,))
single_dates = self.c.fetchall()
for i in single_dates:
print (i)

#take data in order to sum up all costs from one day
for i in single_dates:
print ("***",i)
if tag != "None":
self.c.execute("SELECT Price FROM financial_table WHERE Date = ? AND Tag = ?", (i, tag)) #line 13
else:
self.c.execute("SELECT Price FROM financial_table WHERE Date = ?", (i))
cache = self.c.fetchall()
print (cache)
self.plot_overall_price.append(sum(j for j, in cache)) #save overall price for
self.plot_date.append(i[0]) #a certain date
self.plot_date_days.append(i[0][8:10])


Thank you very much for your help!







python sqlite






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 14:45









SuperShoot

1,845720




1,845720










asked Nov 25 '18 at 11:13









BahlsenBahlsen

286




286








  • 1





    Often when you query for a single column like you have in single_dates the results are returned as a list of tuples e.g., [('date',), ('date',),...]. Are you sure that i in your for loop is just a date string?

    – SuperShoot
    Nov 25 '18 at 11:22
















  • 1





    Often when you query for a single column like you have in single_dates the results are returned as a list of tuples e.g., [('date',), ('date',),...]. Are you sure that i in your for loop is just a date string?

    – SuperShoot
    Nov 25 '18 at 11:22










1




1





Often when you query for a single column like you have in single_dates the results are returned as a list of tuples e.g., [('date',), ('date',),...]. Are you sure that i in your for loop is just a date string?

– SuperShoot
Nov 25 '18 at 11:22







Often when you query for a single column like you have in single_dates the results are returned as a list of tuples e.g., [('date',), ('date',),...]. Are you sure that i in your for loop is just a date string?

– SuperShoot
Nov 25 '18 at 11:22














1 Answer
1






active

oldest

votes


















0














@SuperShoot
Thanks for your help. You were right, i returned "('2018-11-10',)". I fixed my problem by changing row 13 from ...(i,... to ...(i[0],...



However, sometimes is bit of a mystery for me. When tag == "None" then line 15 for example is possible and I don't need the i[0], I can just use i. I mean this line:



self.c.execute("SELECT Price FROM financial_table WHERE Date = ?", (i)) 





share|improve this answer























    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%2f53466887%2fdo-not-understand-error-binding-parameter-0-probably-unsupported-type%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    @SuperShoot
    Thanks for your help. You were right, i returned "('2018-11-10',)". I fixed my problem by changing row 13 from ...(i,... to ...(i[0],...



    However, sometimes is bit of a mystery for me. When tag == "None" then line 15 for example is possible and I don't need the i[0], I can just use i. I mean this line:



    self.c.execute("SELECT Price FROM financial_table WHERE Date = ?", (i)) 





    share|improve this answer




























      0














      @SuperShoot
      Thanks for your help. You were right, i returned "('2018-11-10',)". I fixed my problem by changing row 13 from ...(i,... to ...(i[0],...



      However, sometimes is bit of a mystery for me. When tag == "None" then line 15 for example is possible and I don't need the i[0], I can just use i. I mean this line:



      self.c.execute("SELECT Price FROM financial_table WHERE Date = ?", (i)) 





      share|improve this answer


























        0












        0








        0







        @SuperShoot
        Thanks for your help. You were right, i returned "('2018-11-10',)". I fixed my problem by changing row 13 from ...(i,... to ...(i[0],...



        However, sometimes is bit of a mystery for me. When tag == "None" then line 15 for example is possible and I don't need the i[0], I can just use i. I mean this line:



        self.c.execute("SELECT Price FROM financial_table WHERE Date = ?", (i)) 





        share|improve this answer













        @SuperShoot
        Thanks for your help. You were right, i returned "('2018-11-10',)". I fixed my problem by changing row 13 from ...(i,... to ...(i[0],...



        However, sometimes is bit of a mystery for me. When tag == "None" then line 15 for example is possible and I don't need the i[0], I can just use i. I mean this line:



        self.c.execute("SELECT Price FROM financial_table WHERE Date = ?", (i)) 






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 25 '18 at 12:54









        BahlsenBahlsen

        286




        286
































            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%2f53466887%2fdo-not-understand-error-binding-parameter-0-probably-unsupported-type%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

            Futebolista

            Feedback on college project

            Albești (Vaslui)