Add dictionary or list to Sqlite3 - Gives error operation parameter must be strSQLite3 Integer Max Valuehow can I insert a row in my database from 'adb shell'Sqlite3 gives “Error : Constraint failed” - interfacing to AM1808Python/SQlite3 'str' object is not callableSqlite3: How to check date inputUnsupported type error in sqlite3 using pythonHow to compute a hash of a sqlite database file without causing harmHow do I execute sqlite3 file into a database in mac terminal?how to insert values from csv into sqlite3 using pythonAdding column to sqlite database and distribute rows based on primary key

My professor has told me he will be the corresponding author. Will it hurt my future career?

How do I talk to my wife about unrealistic expectations?

What exactly is a "murder hobo"?

Was it ever illegal to name a pig "Napoleon" in France?

Why SQL does not use the indexed view?

How do ballistic trajectories work in a ring world?

Define functions in a tikzcd diagram

Can a USB hub be used to access a drive from two devices?

How to reclaim personal item I've lent to the office without burning bridges?

Does the Wild Magic sorcerer's Tides of Chaos feature grant advantage on all attacks, or just the first one?

Why are co-factors 4 and 8 so popular when co-factor is more than one?

When is one 'Ready' to make Original Contributions to Mathematics?

What's the difference between a type and a kind?

Why do airports remove/realign runways?

Taking my Ph.D. advisor out for dinner after graduation

How to evaluate the performance of open source solver?

Sense of humor in your sci-fi stories

How do I explain that I don't want to maintain old projects?

Does anyone have a method of differentiating informative comments from commented out code?

Movie featuring a De Lorean - NOT Back to the Future

Examples of fluid (including air) being used to transmit digital data?

Possibility to correct pitch from digital versions of records with the hole not centered

Computer name naming convention for security

Intern not wearing safety equipment; how could I have handled this differently?



Add dictionary or list to Sqlite3 - Gives error operation parameter must be str


SQLite3 Integer Max Valuehow can I insert a row in my database from 'adb shell'Sqlite3 gives “Error : Constraint failed” - interfacing to AM1808Python/SQlite3 'str' object is not callableSqlite3: How to check date inputUnsupported type error in sqlite3 using pythonHow to compute a hash of a sqlite database file without causing harmHow do I execute sqlite3 file into a database in mac terminal?how to insert values from csv into sqlite3 using pythonAdding column to sqlite database and distribute rows based on primary key






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Ok I am new to sqlite and python in general so please be nice =)
I have a simple dictionary -



time = data[0]['timestamp']
price = data[0]['price']

myprice = 'Date':time,'price':price


myprice looks like this (time is a timestamp) -



'Date': 1553549093, 'price': 1.7686


I now want to add the data to sqlite3 database...so I created this -



#Create database if not exist...

db_filename = 'mydb_test.db'
connection = sqlite3.connect(db_filename)

#Get a SQL cursor to be able to execute SQL commands...

cursor = connection.cursor()

#Create table

sql = '''CREATE TABLE IF NOT EXISTS TEST
(PID INTEGER PRIMARY KEY AUTOINCREMENT,
DATE TIMESTAMP,
PRICE FLOAT)'''

#Now lets execute the above SQL

cursor.execute(sql)


#Insert data in sql

sql2 = ("INSERT INTO GBPCAD VALUES (?,?)", [(myprice['Date'],myprice['price'])])

cursor.execute(sql2)
cursor.commit()
connection.close()


But when executing this code I get ValueError: operation parameter must be str



What am I doing wrong?










share|improve this question




























    0















    Ok I am new to sqlite and python in general so please be nice =)
    I have a simple dictionary -



    time = data[0]['timestamp']
    price = data[0]['price']

    myprice = 'Date':time,'price':price


    myprice looks like this (time is a timestamp) -



    'Date': 1553549093, 'price': 1.7686


    I now want to add the data to sqlite3 database...so I created this -



    #Create database if not exist...

    db_filename = 'mydb_test.db'
    connection = sqlite3.connect(db_filename)

    #Get a SQL cursor to be able to execute SQL commands...

    cursor = connection.cursor()

    #Create table

    sql = '''CREATE TABLE IF NOT EXISTS TEST
    (PID INTEGER PRIMARY KEY AUTOINCREMENT,
    DATE TIMESTAMP,
    PRICE FLOAT)'''

    #Now lets execute the above SQL

    cursor.execute(sql)


    #Insert data in sql

    sql2 = ("INSERT INTO GBPCAD VALUES (?,?)", [(myprice['Date'],myprice['price'])])

    cursor.execute(sql2)
    cursor.commit()
    connection.close()


    But when executing this code I get ValueError: operation parameter must be str



    What am I doing wrong?










    share|improve this question
























      0












      0








      0








      Ok I am new to sqlite and python in general so please be nice =)
      I have a simple dictionary -



      time = data[0]['timestamp']
      price = data[0]['price']

      myprice = 'Date':time,'price':price


      myprice looks like this (time is a timestamp) -



      'Date': 1553549093, 'price': 1.7686


      I now want to add the data to sqlite3 database...so I created this -



      #Create database if not exist...

      db_filename = 'mydb_test.db'
      connection = sqlite3.connect(db_filename)

      #Get a SQL cursor to be able to execute SQL commands...

      cursor = connection.cursor()

      #Create table

      sql = '''CREATE TABLE IF NOT EXISTS TEST
      (PID INTEGER PRIMARY KEY AUTOINCREMENT,
      DATE TIMESTAMP,
      PRICE FLOAT)'''

      #Now lets execute the above SQL

      cursor.execute(sql)


      #Insert data in sql

      sql2 = ("INSERT INTO GBPCAD VALUES (?,?)", [(myprice['Date'],myprice['price'])])

      cursor.execute(sql2)
      cursor.commit()
      connection.close()


      But when executing this code I get ValueError: operation parameter must be str



      What am I doing wrong?










      share|improve this question














      Ok I am new to sqlite and python in general so please be nice =)
      I have a simple dictionary -



      time = data[0]['timestamp']
      price = data[0]['price']

      myprice = 'Date':time,'price':price


      myprice looks like this (time is a timestamp) -



      'Date': 1553549093, 'price': 1.7686


      I now want to add the data to sqlite3 database...so I created this -



      #Create database if not exist...

      db_filename = 'mydb_test.db'
      connection = sqlite3.connect(db_filename)

      #Get a SQL cursor to be able to execute SQL commands...

      cursor = connection.cursor()

      #Create table

      sql = '''CREATE TABLE IF NOT EXISTS TEST
      (PID INTEGER PRIMARY KEY AUTOINCREMENT,
      DATE TIMESTAMP,
      PRICE FLOAT)'''

      #Now lets execute the above SQL

      cursor.execute(sql)


      #Insert data in sql

      sql2 = ("INSERT INTO GBPCAD VALUES (?,?)", [(myprice['Date'],myprice['price'])])

      cursor.execute(sql2)
      cursor.commit()
      connection.close()


      But when executing this code I get ValueError: operation parameter must be str



      What am I doing wrong?







      sqlite python-3.6






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 21:40









      Slavia888Slavia888

      527 bronze badges




      527 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Pass the arguments of the insert statement in execute():



          sql2 = "INSERT INTO GBPCAD (DATE, PRICE) VALUES (?,?)"
          cursor.execute(sql2, (myprice['Date'], myprice['price']))


          Also include in the insert statement the names of the columns.






          share|improve this answer























          • Thanks for taking time to answer. Error message gone but no data is added to db. Have to check somehow where problem is.

            – Slavia888
            Mar 26 at 22:28











          • The create statement in your code creates a table named TEST but the insert statement adds a row to a table GBPCAD. Why?

            – forpas
            Mar 26 at 22:38











          • Forpas you are fast =) I solved it. It was my bad using gbpcad as table-name in example. What was the problem was - connection.commit() and not cursor.commit() Everything works like a champion! And so are you! Many thanks!

            – Slavia888
            Mar 26 at 22:47












          • Fine if it is solved.

            – forpas
            Mar 26 at 22:49










          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%2f55346827%2fadd-dictionary-or-list-to-sqlite3-gives-error-operation-parameter-must-be-str%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









          1














          Pass the arguments of the insert statement in execute():



          sql2 = "INSERT INTO GBPCAD (DATE, PRICE) VALUES (?,?)"
          cursor.execute(sql2, (myprice['Date'], myprice['price']))


          Also include in the insert statement the names of the columns.






          share|improve this answer























          • Thanks for taking time to answer. Error message gone but no data is added to db. Have to check somehow where problem is.

            – Slavia888
            Mar 26 at 22:28











          • The create statement in your code creates a table named TEST but the insert statement adds a row to a table GBPCAD. Why?

            – forpas
            Mar 26 at 22:38











          • Forpas you are fast =) I solved it. It was my bad using gbpcad as table-name in example. What was the problem was - connection.commit() and not cursor.commit() Everything works like a champion! And so are you! Many thanks!

            – Slavia888
            Mar 26 at 22:47












          • Fine if it is solved.

            – forpas
            Mar 26 at 22:49















          1














          Pass the arguments of the insert statement in execute():



          sql2 = "INSERT INTO GBPCAD (DATE, PRICE) VALUES (?,?)"
          cursor.execute(sql2, (myprice['Date'], myprice['price']))


          Also include in the insert statement the names of the columns.






          share|improve this answer























          • Thanks for taking time to answer. Error message gone but no data is added to db. Have to check somehow where problem is.

            – Slavia888
            Mar 26 at 22:28











          • The create statement in your code creates a table named TEST but the insert statement adds a row to a table GBPCAD. Why?

            – forpas
            Mar 26 at 22:38











          • Forpas you are fast =) I solved it. It was my bad using gbpcad as table-name in example. What was the problem was - connection.commit() and not cursor.commit() Everything works like a champion! And so are you! Many thanks!

            – Slavia888
            Mar 26 at 22:47












          • Fine if it is solved.

            – forpas
            Mar 26 at 22:49













          1












          1








          1







          Pass the arguments of the insert statement in execute():



          sql2 = "INSERT INTO GBPCAD (DATE, PRICE) VALUES (?,?)"
          cursor.execute(sql2, (myprice['Date'], myprice['price']))


          Also include in the insert statement the names of the columns.






          share|improve this answer













          Pass the arguments of the insert statement in execute():



          sql2 = "INSERT INTO GBPCAD (DATE, PRICE) VALUES (?,?)"
          cursor.execute(sql2, (myprice['Date'], myprice['price']))


          Also include in the insert statement the names of the columns.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 22:10









          forpasforpas

          32.1k5 gold badges11 silver badges30 bronze badges




          32.1k5 gold badges11 silver badges30 bronze badges












          • Thanks for taking time to answer. Error message gone but no data is added to db. Have to check somehow where problem is.

            – Slavia888
            Mar 26 at 22:28











          • The create statement in your code creates a table named TEST but the insert statement adds a row to a table GBPCAD. Why?

            – forpas
            Mar 26 at 22:38











          • Forpas you are fast =) I solved it. It was my bad using gbpcad as table-name in example. What was the problem was - connection.commit() and not cursor.commit() Everything works like a champion! And so are you! Many thanks!

            – Slavia888
            Mar 26 at 22:47












          • Fine if it is solved.

            – forpas
            Mar 26 at 22:49

















          • Thanks for taking time to answer. Error message gone but no data is added to db. Have to check somehow where problem is.

            – Slavia888
            Mar 26 at 22:28











          • The create statement in your code creates a table named TEST but the insert statement adds a row to a table GBPCAD. Why?

            – forpas
            Mar 26 at 22:38











          • Forpas you are fast =) I solved it. It was my bad using gbpcad as table-name in example. What was the problem was - connection.commit() and not cursor.commit() Everything works like a champion! And so are you! Many thanks!

            – Slavia888
            Mar 26 at 22:47












          • Fine if it is solved.

            – forpas
            Mar 26 at 22:49
















          Thanks for taking time to answer. Error message gone but no data is added to db. Have to check somehow where problem is.

          – Slavia888
          Mar 26 at 22:28





          Thanks for taking time to answer. Error message gone but no data is added to db. Have to check somehow where problem is.

          – Slavia888
          Mar 26 at 22:28













          The create statement in your code creates a table named TEST but the insert statement adds a row to a table GBPCAD. Why?

          – forpas
          Mar 26 at 22:38





          The create statement in your code creates a table named TEST but the insert statement adds a row to a table GBPCAD. Why?

          – forpas
          Mar 26 at 22:38













          Forpas you are fast =) I solved it. It was my bad using gbpcad as table-name in example. What was the problem was - connection.commit() and not cursor.commit() Everything works like a champion! And so are you! Many thanks!

          – Slavia888
          Mar 26 at 22:47






          Forpas you are fast =) I solved it. It was my bad using gbpcad as table-name in example. What was the problem was - connection.commit() and not cursor.commit() Everything works like a champion! And so are you! Many thanks!

          – Slavia888
          Mar 26 at 22:47














          Fine if it is solved.

          – forpas
          Mar 26 at 22:49





          Fine if it is solved.

          – forpas
          Mar 26 at 22:49








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          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%2f55346827%2fadd-dictionary-or-list-to-sqlite3-gives-error-operation-parameter-must-be-str%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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          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

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현