Pace Maker in Select statement not working












0














Select statement in sqlite3(Python) without pacemaker is working fine but is behaving odd with the pacemaker(?)



In the below code when I'm using "table_column_name" in the select I am getting all the items in my list populated in my list box. but when I am passing it as tuple to select statement with the help of pacemaker my list bosx has only one entry i.e "table_column_name".



class ListObj(tkinter.Listbox):

def __init__(self, window, cname, r, c, rs, cs, sticky, bg,
padx=5, pady=5, ipadx=0, ipady=0, **kwargs):

self = tkinter.Listbox(window)

self.grid(row=r, column=c, rowspan=rs, columnspan=cs,
sticky=sticky, padx=padx, pady=pady,
ipadx=ipadx, ipady=ipady)

List = cursor.execute(f"SELECT DISTINCT ? FROM juke_box",
(cname,))

for x in List:
print(x)
self.insert(tkinter.END, x)


list_box= ListObj(root, 'table_column_name',1,0,2,1,'nsew', 'sky blue')


my expected outcome is that I should get all the items in the column name passed as tuple should populate in the tk list.










share|improve this question
























  • nothing in your code uses pacemaker as far as I can see. What relevance has it for an sql-query? how does it help us reproduce your error as a Minimal, Complete, and Verifiable example should?
    – Patrick Artner
    Dec 28 '18 at 10:14


















0














Select statement in sqlite3(Python) without pacemaker is working fine but is behaving odd with the pacemaker(?)



In the below code when I'm using "table_column_name" in the select I am getting all the items in my list populated in my list box. but when I am passing it as tuple to select statement with the help of pacemaker my list bosx has only one entry i.e "table_column_name".



class ListObj(tkinter.Listbox):

def __init__(self, window, cname, r, c, rs, cs, sticky, bg,
padx=5, pady=5, ipadx=0, ipady=0, **kwargs):

self = tkinter.Listbox(window)

self.grid(row=r, column=c, rowspan=rs, columnspan=cs,
sticky=sticky, padx=padx, pady=pady,
ipadx=ipadx, ipady=ipady)

List = cursor.execute(f"SELECT DISTINCT ? FROM juke_box",
(cname,))

for x in List:
print(x)
self.insert(tkinter.END, x)


list_box= ListObj(root, 'table_column_name',1,0,2,1,'nsew', 'sky blue')


my expected outcome is that I should get all the items in the column name passed as tuple should populate in the tk list.










share|improve this question
























  • nothing in your code uses pacemaker as far as I can see. What relevance has it for an sql-query? how does it help us reproduce your error as a Minimal, Complete, and Verifiable example should?
    – Patrick Artner
    Dec 28 '18 at 10:14
















0












0








0







Select statement in sqlite3(Python) without pacemaker is working fine but is behaving odd with the pacemaker(?)



In the below code when I'm using "table_column_name" in the select I am getting all the items in my list populated in my list box. but when I am passing it as tuple to select statement with the help of pacemaker my list bosx has only one entry i.e "table_column_name".



class ListObj(tkinter.Listbox):

def __init__(self, window, cname, r, c, rs, cs, sticky, bg,
padx=5, pady=5, ipadx=0, ipady=0, **kwargs):

self = tkinter.Listbox(window)

self.grid(row=r, column=c, rowspan=rs, columnspan=cs,
sticky=sticky, padx=padx, pady=pady,
ipadx=ipadx, ipady=ipady)

List = cursor.execute(f"SELECT DISTINCT ? FROM juke_box",
(cname,))

for x in List:
print(x)
self.insert(tkinter.END, x)


list_box= ListObj(root, 'table_column_name',1,0,2,1,'nsew', 'sky blue')


my expected outcome is that I should get all the items in the column name passed as tuple should populate in the tk list.










share|improve this question















Select statement in sqlite3(Python) without pacemaker is working fine but is behaving odd with the pacemaker(?)



In the below code when I'm using "table_column_name" in the select I am getting all the items in my list populated in my list box. but when I am passing it as tuple to select statement with the help of pacemaker my list bosx has only one entry i.e "table_column_name".



class ListObj(tkinter.Listbox):

def __init__(self, window, cname, r, c, rs, cs, sticky, bg,
padx=5, pady=5, ipadx=0, ipady=0, **kwargs):

self = tkinter.Listbox(window)

self.grid(row=r, column=c, rowspan=rs, columnspan=cs,
sticky=sticky, padx=padx, pady=pady,
ipadx=ipadx, ipady=ipady)

List = cursor.execute(f"SELECT DISTINCT ? FROM juke_box",
(cname,))

for x in List:
print(x)
self.insert(tkinter.END, x)


list_box= ListObj(root, 'table_column_name',1,0,2,1,'nsew', 'sky blue')


my expected outcome is that I should get all the items in the column name passed as tuple should populate in the tk list.







python python-3.x sqlite3 pacemaker






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 28 '18 at 10:37









Patrick Artner

22.2k62143




22.2k62143










asked Dec 28 '18 at 9:38









user9977436user9977436

135




135












  • nothing in your code uses pacemaker as far as I can see. What relevance has it for an sql-query? how does it help us reproduce your error as a Minimal, Complete, and Verifiable example should?
    – Patrick Artner
    Dec 28 '18 at 10:14




















  • nothing in your code uses pacemaker as far as I can see. What relevance has it for an sql-query? how does it help us reproduce your error as a Minimal, Complete, and Verifiable example should?
    – Patrick Artner
    Dec 28 '18 at 10:14


















nothing in your code uses pacemaker as far as I can see. What relevance has it for an sql-query? how does it help us reproduce your error as a Minimal, Complete, and Verifiable example should?
– Patrick Artner
Dec 28 '18 at 10:14






nothing in your code uses pacemaker as far as I can see. What relevance has it for an sql-query? how does it help us reproduce your error as a Minimal, Complete, and Verifiable example should?
– Patrick Artner
Dec 28 '18 at 10:14














1 Answer
1






active

oldest

votes


















0














List = cursor.execute(f"SELECT DISTINCT ? FROM juke_box", 
(cname,))


Looks like you're trying to pass a column name as a bound parameter. You can't do that; table and column names have to be present in the SQL statement when it's compiled, not passed at execution time. The cname variable is being bound as a string, and that string returned. Because it's a SELECT DISTINCT, and every row of the table ends up selecting the same 'table_column_name' string, only one row with that value is being returned. That whole query basically can be reduced to SELECT ? where the question mark is replaced by the string in cname.






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%2f53956405%2fpace-maker-in-select-statement-not-working%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














    List = cursor.execute(f"SELECT DISTINCT ? FROM juke_box", 
    (cname,))


    Looks like you're trying to pass a column name as a bound parameter. You can't do that; table and column names have to be present in the SQL statement when it's compiled, not passed at execution time. The cname variable is being bound as a string, and that string returned. Because it's a SELECT DISTINCT, and every row of the table ends up selecting the same 'table_column_name' string, only one row with that value is being returned. That whole query basically can be reduced to SELECT ? where the question mark is replaced by the string in cname.






    share|improve this answer


























      0














      List = cursor.execute(f"SELECT DISTINCT ? FROM juke_box", 
      (cname,))


      Looks like you're trying to pass a column name as a bound parameter. You can't do that; table and column names have to be present in the SQL statement when it's compiled, not passed at execution time. The cname variable is being bound as a string, and that string returned. Because it's a SELECT DISTINCT, and every row of the table ends up selecting the same 'table_column_name' string, only one row with that value is being returned. That whole query basically can be reduced to SELECT ? where the question mark is replaced by the string in cname.






      share|improve this answer
























        0












        0








        0






        List = cursor.execute(f"SELECT DISTINCT ? FROM juke_box", 
        (cname,))


        Looks like you're trying to pass a column name as a bound parameter. You can't do that; table and column names have to be present in the SQL statement when it's compiled, not passed at execution time. The cname variable is being bound as a string, and that string returned. Because it's a SELECT DISTINCT, and every row of the table ends up selecting the same 'table_column_name' string, only one row with that value is being returned. That whole query basically can be reduced to SELECT ? where the question mark is replaced by the string in cname.






        share|improve this answer












        List = cursor.execute(f"SELECT DISTINCT ? FROM juke_box", 
        (cname,))


        Looks like you're trying to pass a column name as a bound parameter. You can't do that; table and column names have to be present in the SQL statement when it's compiled, not passed at execution time. The cname variable is being bound as a string, and that string returned. Because it's a SELECT DISTINCT, and every row of the table ends up selecting the same 'table_column_name' string, only one row with that value is being returned. That whole query basically can be reduced to SELECT ? where the question mark is replaced by the string in cname.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 28 '18 at 11:52









        ShawnShawn

        3,5731613




        3,5731613






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f53956405%2fpace-maker-in-select-statement-not-working%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

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas