Can an arbitary column name be used in sqlite3 db?Variable table name in sqliteWhat SQLite column name can be/cannot be?creating Tables and columns dynamically using mysql python connectorCalling a function of a module by using its name (a string)How can I safely create a nested directory in Python?How can I make a time delay in Python?Delete column from pandas DataFrame by column namesqlite3.OperationalError: near “,”: syntax errorSqlite3 & Python creating tablesHow to get columns' name from a table in sqlite3 database using python3?Error in IF NOT EXISTS sqlite3Error with Sqllite3 reading .sql filesqlite3.OperationalError: near “index”: syntax error

How does Captain America channel this power?

How come there are so many candidates for the 2020 Democratic party presidential nomination?

How to pronounce 'c++' in Spanish

Does tea made with boiling water cool faster than tea made with boiled (but still hot) water?

How can I get this effect? Please see the attached image

Critique of timeline aesthetic

Coordinate my way to the name of the (video) game

What does the integral of a function times a function of a random variable represent, conceptually?

Why does Mind Blank stop the Feeblemind spell?

Two field separators (colon and space) in awk

How did Captain America manage to do this?

Elements that can bond to themselves?

"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?

How to limit Drive Letters Windows assigns to new removable USB drives

Rivers without rain

Can I criticise the more senior developers around me for not writing clean code?

Implications of cigar-shaped bodies having rings?

Don’t seats that recline flat defeat the purpose of having seatbelts?

How exactly does Hawking radiation decrease the mass of black holes?

How would 10 generations of living underground change the human body?

Minor Revision with suggestion of an alternative proof by reviewer

What happens to Mjolnir (Thor's hammer) at the end of Endgame?

How to have a sharp product image?

What are the steps to solving this definite integral?



Can an arbitary column name be used in sqlite3 db?


Variable table name in sqliteWhat SQLite column name can be/cannot be?creating Tables and columns dynamically using mysql python connectorCalling a function of a module by using its name (a string)How can I safely create a nested directory in Python?How can I make a time delay in Python?Delete column from pandas DataFrame by column namesqlite3.OperationalError: near “,”: syntax errorSqlite3 & Python creating tablesHow to get columns' name from a table in sqlite3 database using python3?Error in IF NOT EXISTS sqlite3Error with Sqllite3 reading .sql filesqlite3.OperationalError: near “index”: syntax error






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








0















I am trying to use ? to allow me to set arbitrary column names.



import sqlite3
conn = sqlite3.connect(':memory:')
c = conn.cursor()
c.execute("create table mytab (? text, ? real)", ('v1', 'v2'))


But I got the following error. So it is not possible to use ? when creating tables?



Traceback (most recent call last):
File "/tmp/main1.py", line 10, in <module>
c.execute("create table mytab (? text, ? real)", ('v1', 'v2'))
sqlite3.OperationalError: near "?": syntax error









share|improve this question






















  • Possible duplicate of Variable table name in sqlite (table/column names are equivalent in relation to the question)

    – Alex K.
    Mar 22 at 17:35


















0















I am trying to use ? to allow me to set arbitrary column names.



import sqlite3
conn = sqlite3.connect(':memory:')
c = conn.cursor()
c.execute("create table mytab (? text, ? real)", ('v1', 'v2'))


But I got the following error. So it is not possible to use ? when creating tables?



Traceback (most recent call last):
File "/tmp/main1.py", line 10, in <module>
c.execute("create table mytab (? text, ? real)", ('v1', 'v2'))
sqlite3.OperationalError: near "?": syntax error









share|improve this question






















  • Possible duplicate of Variable table name in sqlite (table/column names are equivalent in relation to the question)

    – Alex K.
    Mar 22 at 17:35














0












0








0








I am trying to use ? to allow me to set arbitrary column names.



import sqlite3
conn = sqlite3.connect(':memory:')
c = conn.cursor()
c.execute("create table mytab (? text, ? real)", ('v1', 'v2'))


But I got the following error. So it is not possible to use ? when creating tables?



Traceback (most recent call last):
File "/tmp/main1.py", line 10, in <module>
c.execute("create table mytab (? text, ? real)", ('v1', 'v2'))
sqlite3.OperationalError: near "?": syntax error









share|improve this question














I am trying to use ? to allow me to set arbitrary column names.



import sqlite3
conn = sqlite3.connect(':memory:')
c = conn.cursor()
c.execute("create table mytab (? text, ? real)", ('v1', 'v2'))


But I got the following error. So it is not possible to use ? when creating tables?



Traceback (most recent call last):
File "/tmp/main1.py", line 10, in <module>
c.execute("create table mytab (? text, ? real)", ('v1', 'v2'))
sqlite3.OperationalError: near "?": syntax error






python sqlite3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 22 at 17:30









user1424739user1424739

1,30041733




1,30041733












  • Possible duplicate of Variable table name in sqlite (table/column names are equivalent in relation to the question)

    – Alex K.
    Mar 22 at 17:35


















  • Possible duplicate of Variable table name in sqlite (table/column names are equivalent in relation to the question)

    – Alex K.
    Mar 22 at 17:35

















Possible duplicate of Variable table name in sqlite (table/column names are equivalent in relation to the question)

– Alex K.
Mar 22 at 17:35






Possible duplicate of Variable table name in sqlite (table/column names are equivalent in relation to the question)

– Alex K.
Mar 22 at 17:35













2 Answers
2






active

oldest

votes


















0














try something like this instead?



"create table mytab ( text, real)".format('v1', 'v2')






share|improve this answer


















  • 1





    Hi! while this answer may solve OP's problem, it is discouraged to post code only answers on SO. Providing some explanation will help OP understand this solution better, while also contributing to SO's mission of providing quality solutions to future users of the site. Thanks!

    – d_kennetz
    Mar 22 at 17:58











  • Does this allow arbitrary column names?

    – user1424739
    Mar 22 at 18:18











  • what do you mean by arbitrary column names?

    – Yongkang Zhao
    Mar 22 at 18:56











  • For example, a column name that contains any ASCII code (such as ESC).

    – user1424739
    Mar 22 at 20:38












  • I have no idea, but I found this page, and could be useful for you. check user35443's answer: stackoverflow.com/questions/3373234/…

    – Yongkang Zhao
    Mar 25 at 21:10


















0














The SQL parameter substitution is the solution SQL injection. It tries to separate the functional components (e.g. the keyword SELECT, the statement separator ;, etc) and data components (e.g. the number, strings, etc that are data that totally not related to the SQL function)



The point of parameter is to request to properly escape the input data if needed before passing on to the SQL engine, so data stays data, and functional components are functional components.



So you can do:



SELECT x FROM table_y WHERE z = ?


and pass on '""; DROP TABLE table_y' as parameter, and that is exactly a string to match. But you cannot do:



SELECT x FROM table_y WHERE ? = '""; DROP TABLE table_y'


and pass on 'z' as parameter and expect it to mean the same. Because when you pass in 'z', it is interpreted as string, not column name. Having this idea, you will see that the SQL on your example will only evolve into SQL syntax error.






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%2f55304951%2fcan-an-arbitary-column-name-be-used-in-sqlite3-db%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    try something like this instead?



    "create table mytab ( text, real)".format('v1', 'v2')






    share|improve this answer


















    • 1





      Hi! while this answer may solve OP's problem, it is discouraged to post code only answers on SO. Providing some explanation will help OP understand this solution better, while also contributing to SO's mission of providing quality solutions to future users of the site. Thanks!

      – d_kennetz
      Mar 22 at 17:58











    • Does this allow arbitrary column names?

      – user1424739
      Mar 22 at 18:18











    • what do you mean by arbitrary column names?

      – Yongkang Zhao
      Mar 22 at 18:56











    • For example, a column name that contains any ASCII code (such as ESC).

      – user1424739
      Mar 22 at 20:38












    • I have no idea, but I found this page, and could be useful for you. check user35443's answer: stackoverflow.com/questions/3373234/…

      – Yongkang Zhao
      Mar 25 at 21:10















    0














    try something like this instead?



    "create table mytab ( text, real)".format('v1', 'v2')






    share|improve this answer


















    • 1





      Hi! while this answer may solve OP's problem, it is discouraged to post code only answers on SO. Providing some explanation will help OP understand this solution better, while also contributing to SO's mission of providing quality solutions to future users of the site. Thanks!

      – d_kennetz
      Mar 22 at 17:58











    • Does this allow arbitrary column names?

      – user1424739
      Mar 22 at 18:18











    • what do you mean by arbitrary column names?

      – Yongkang Zhao
      Mar 22 at 18:56











    • For example, a column name that contains any ASCII code (such as ESC).

      – user1424739
      Mar 22 at 20:38












    • I have no idea, but I found this page, and could be useful for you. check user35443's answer: stackoverflow.com/questions/3373234/…

      – Yongkang Zhao
      Mar 25 at 21:10













    0












    0








    0







    try something like this instead?



    "create table mytab ( text, real)".format('v1', 'v2')






    share|improve this answer













    try something like this instead?



    "create table mytab ( text, real)".format('v1', 'v2')







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 22 at 17:38









    Yongkang ZhaoYongkang Zhao

    428211




    428211







    • 1





      Hi! while this answer may solve OP's problem, it is discouraged to post code only answers on SO. Providing some explanation will help OP understand this solution better, while also contributing to SO's mission of providing quality solutions to future users of the site. Thanks!

      – d_kennetz
      Mar 22 at 17:58











    • Does this allow arbitrary column names?

      – user1424739
      Mar 22 at 18:18











    • what do you mean by arbitrary column names?

      – Yongkang Zhao
      Mar 22 at 18:56











    • For example, a column name that contains any ASCII code (such as ESC).

      – user1424739
      Mar 22 at 20:38












    • I have no idea, but I found this page, and could be useful for you. check user35443's answer: stackoverflow.com/questions/3373234/…

      – Yongkang Zhao
      Mar 25 at 21:10












    • 1





      Hi! while this answer may solve OP's problem, it is discouraged to post code only answers on SO. Providing some explanation will help OP understand this solution better, while also contributing to SO's mission of providing quality solutions to future users of the site. Thanks!

      – d_kennetz
      Mar 22 at 17:58











    • Does this allow arbitrary column names?

      – user1424739
      Mar 22 at 18:18











    • what do you mean by arbitrary column names?

      – Yongkang Zhao
      Mar 22 at 18:56











    • For example, a column name that contains any ASCII code (such as ESC).

      – user1424739
      Mar 22 at 20:38












    • I have no idea, but I found this page, and could be useful for you. check user35443's answer: stackoverflow.com/questions/3373234/…

      – Yongkang Zhao
      Mar 25 at 21:10







    1




    1





    Hi! while this answer may solve OP's problem, it is discouraged to post code only answers on SO. Providing some explanation will help OP understand this solution better, while also contributing to SO's mission of providing quality solutions to future users of the site. Thanks!

    – d_kennetz
    Mar 22 at 17:58





    Hi! while this answer may solve OP's problem, it is discouraged to post code only answers on SO. Providing some explanation will help OP understand this solution better, while also contributing to SO's mission of providing quality solutions to future users of the site. Thanks!

    – d_kennetz
    Mar 22 at 17:58













    Does this allow arbitrary column names?

    – user1424739
    Mar 22 at 18:18





    Does this allow arbitrary column names?

    – user1424739
    Mar 22 at 18:18













    what do you mean by arbitrary column names?

    – Yongkang Zhao
    Mar 22 at 18:56





    what do you mean by arbitrary column names?

    – Yongkang Zhao
    Mar 22 at 18:56













    For example, a column name that contains any ASCII code (such as ESC).

    – user1424739
    Mar 22 at 20:38






    For example, a column name that contains any ASCII code (such as ESC).

    – user1424739
    Mar 22 at 20:38














    I have no idea, but I found this page, and could be useful for you. check user35443's answer: stackoverflow.com/questions/3373234/…

    – Yongkang Zhao
    Mar 25 at 21:10





    I have no idea, but I found this page, and could be useful for you. check user35443's answer: stackoverflow.com/questions/3373234/…

    – Yongkang Zhao
    Mar 25 at 21:10













    0














    The SQL parameter substitution is the solution SQL injection. It tries to separate the functional components (e.g. the keyword SELECT, the statement separator ;, etc) and data components (e.g. the number, strings, etc that are data that totally not related to the SQL function)



    The point of parameter is to request to properly escape the input data if needed before passing on to the SQL engine, so data stays data, and functional components are functional components.



    So you can do:



    SELECT x FROM table_y WHERE z = ?


    and pass on '""; DROP TABLE table_y' as parameter, and that is exactly a string to match. But you cannot do:



    SELECT x FROM table_y WHERE ? = '""; DROP TABLE table_y'


    and pass on 'z' as parameter and expect it to mean the same. Because when you pass in 'z', it is interpreted as string, not column name. Having this idea, you will see that the SQL on your example will only evolve into SQL syntax error.






    share|improve this answer



























      0














      The SQL parameter substitution is the solution SQL injection. It tries to separate the functional components (e.g. the keyword SELECT, the statement separator ;, etc) and data components (e.g. the number, strings, etc that are data that totally not related to the SQL function)



      The point of parameter is to request to properly escape the input data if needed before passing on to the SQL engine, so data stays data, and functional components are functional components.



      So you can do:



      SELECT x FROM table_y WHERE z = ?


      and pass on '""; DROP TABLE table_y' as parameter, and that is exactly a string to match. But you cannot do:



      SELECT x FROM table_y WHERE ? = '""; DROP TABLE table_y'


      and pass on 'z' as parameter and expect it to mean the same. Because when you pass in 'z', it is interpreted as string, not column name. Having this idea, you will see that the SQL on your example will only evolve into SQL syntax error.






      share|improve this answer

























        0












        0








        0







        The SQL parameter substitution is the solution SQL injection. It tries to separate the functional components (e.g. the keyword SELECT, the statement separator ;, etc) and data components (e.g. the number, strings, etc that are data that totally not related to the SQL function)



        The point of parameter is to request to properly escape the input data if needed before passing on to the SQL engine, so data stays data, and functional components are functional components.



        So you can do:



        SELECT x FROM table_y WHERE z = ?


        and pass on '""; DROP TABLE table_y' as parameter, and that is exactly a string to match. But you cannot do:



        SELECT x FROM table_y WHERE ? = '""; DROP TABLE table_y'


        and pass on 'z' as parameter and expect it to mean the same. Because when you pass in 'z', it is interpreted as string, not column name. Having this idea, you will see that the SQL on your example will only evolve into SQL syntax error.






        share|improve this answer













        The SQL parameter substitution is the solution SQL injection. It tries to separate the functional components (e.g. the keyword SELECT, the statement separator ;, etc) and data components (e.g. the number, strings, etc that are data that totally not related to the SQL function)



        The point of parameter is to request to properly escape the input data if needed before passing on to the SQL engine, so data stays data, and functional components are functional components.



        So you can do:



        SELECT x FROM table_y WHERE z = ?


        and pass on '""; DROP TABLE table_y' as parameter, and that is exactly a string to match. But you cannot do:



        SELECT x FROM table_y WHERE ? = '""; DROP TABLE table_y'


        and pass on 'z' as parameter and expect it to mean the same. Because when you pass in 'z', it is interpreted as string, not column name. Having this idea, you will see that the SQL on your example will only evolve into SQL syntax error.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 22 at 17:51









        adrtamadrtam

        3,5151422




        3,5151422



























            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%2f55304951%2fcan-an-arbitary-column-name-be-used-in-sqlite3-db%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

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해