I am getting a strange SQL error when trying to push a dataframe to sql. My df
is just a pandas dataframe that I am trying to push to my SQL database. I have never had a problem before and the error message is very uninformative as to what the problem is. The error is similar to this: MySQL - Operand should contain 1 column(s)
although I am using python.
A .head()
of my df
looks as such and the code to push and my error looks as such:
uuid ... source.imageUrls.large
0 fe768572-c96c-4936-8138-3ac09e75c4cc ... https://cityfalconproduction.blob.core.windows...
1 eb8bddac-56f7-4ed6-a214-325a97ce6104 ... https://cityfalconproduction.blob.core.windows...
2 a89899e0-e34b-416e-a8b3-387fb7293b90 ... https://cityfalconproduction.blob.core.windows...
3 9340719e-68c8-4281-860f-895b3b54644f ... https://cityfalconproduction.blob.core.windows...
4 a369b1e7-1496-4614-b866-b8d48cce9713 ... https://cityfalconproduction.blob.core.windows...
[5 rows x 23 columns]
df.to_sql('news', con=engine, if_exists='append', index=False)
--> sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1241, 'Operand should contain 1 column(s)')
[SQL: INSERT INTO news_articlesz (`index`, uuid, `publishTime`, title, description, `assetTags`, `searchTags`, category, url, `imageUrls`, sentiment, lang, `cityfalconScore`, `duplicatesCount`, paywall, `registrationRequired`, cityfalcon_permalink, `source.name`, `source.brandName`, `source.imageUrl`, `source.imageUrls.thumb`, `source.imageUrls.small`, `source.imageUrls.medium`, `source.imageUrls.large`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)]
[parameters: ((0, 'fe768572-c96c-4936-8138-3ac09e75c4cc', '2021-04-08T15:49:00.000Z', 'Microsoft approaches $2 trillion in market value as its stock hits record high', "Microsoft is closing in on a $2 trillion market capitalization. It would be only the second US company after Apple to pass that threshold. The computing titan's", ['Apple Inc', 'AAPL NASDAQ', 'AAPL US'], ['AAPL'], 'major_publication', 'https://www.businessinsider.in/stock-market/news/microsoft-approaches-2-trillion-in-market-value-as-its-stock-hits-record-high/articleshow/81973984.cms?utm_campaign=cityfalcon&utm_medium=cityfalcon&utm_source=cityfalcon', ['https://www.businessinsider.in/photo/81973984/microsoft-approaches-2-trillion-in-market-value-as-its-stock-hits-record-high.jpg?imgsize=253771'], None, 'en', 67, 11, 0, 0, 'https://www.cityfalcon.com/news/directory/stocks/apple-inc-aapl', 'businessinsider.in', 'Business Insider India', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/3333/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/3333/thumb.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/3333/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/3333/medium.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/3333/large.png'), (1, 'eb8bddac-56f7-4ed6-a214-325a97ce6104', '2021-04-13T16:53:09.000Z', 'Epic announces billion-dollar funding round ahead of Apple trial | Engadget', 'Sony has increased its stake in the company with a $200 million investment.', ['Apple Inc', 'AAPL NASDAQ', 'AAPL US'], ['AAPL'], 'other_publication', 'https://www.engadget.com/epic-billion-dollar-funding-round-sony-app-store-lawsuit-apple-165309621.html?utm_campaign=cityfalcon&utm_medium=cityfalcon&utm_source=cityfalcon', ['https://s.yimg.com/os/creatr-uploaded-images/2021-04/b3369ea0-9c75-11eb-bf4f-12ab7ed0bb34'], None, 'en', 65, 25, 0, 0, 'https://www.cityfalcon.com/news/directory/stocks/apple-inc-aapl', 'engadget.com', 'Engadget', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/2955/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/2955/thumb.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/2955/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/2955/medium.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/2955/large.png'), (2, 'a89899e0-e34b-416e-a8b3-387fb7293b90', '2021-04-11T17:20:09.198Z', 'Microsoft in talks to buy Burlington AI and technology firm Nuance Communications, sources say - The Boston Globe', "The deal would value Nuance, which laid the groundwork for the technology used in Apple's Siri voice software, at about $16 billion, according to data compiled by Bloomberg.", ['Apple Inc', 'AAPL NASDAQ', 'AAPL US'], ['AAPL'], 'other_publication', 'https://www.bostonglobe.com/2021/04/11/business/microsoft-talks-buy-burlington-ai-technology-firm-nuance-communications/?camp=bg%3Abrief%3Arss%3Afeedly&rss_id=feedly_rss_brief&s_campaign=bostonglobe%3Asocialflow%3Atwitter&utm_campaign=cityfalcon&utm_medium=cityfalcon&utm_source=cityfalcon', ['https://bostonglobe-prod.cdn.arcpublishing.com/resizer/KujNh-uiIXPqgdfA0HuVA5z2cWg=/506x0/cloudfront-us-east-1.images.arcpublishing.com/bostonglobe/XKNGLJFHLGSTCOZUB4IGSBSLRI.jpg'], None, 'en', 62, 0, 0, 0, 'https://www.cityfalcon.com/news/directory/stocks/apple-inc-aapl', 'bostonglobe.com', 'The Boston Globe', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1679073/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1679073/thumb.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1679073/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1679073/medium.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1679073/large.png'), (3, '9340719e-68c8-4281-860f-895b3b54644f', '2021-04-13T16:32:32.000Z', 'Apple confirms Spring Loaded April 20 event, new iPad Pro expected', 'Apple is likely to launch new iPad Pro model at its April 20 event.', ['Apple Inc', 'AAPL NASDAQ', 'AAPL US'], ['AAPL'], 'other_publication', 'https://www.indiatoday.in/technology/news/story/apple-confirms-spring-loaded-april-20-event-new-ipad-pro-expected-1790602-2021-04-13?utm_campaign=cityfalcon&utm_medium=cityfalcon&utm_source=cityfalcon', ['https://akm-img-a-in.tosshub.com/indiatoday/images/story/202104/apple-event-Spring-647x363.jpeg?3g.1QDt3MEp9uerkfC41JPKpFPWPl5vl'], '35.06', 'en', 61, 5, 0, 0, 'https://www.cityfalcon.com/news/directory/stocks/apple-inc-aapl', 'indiatoday.in', 'India Today', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/13110/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/13110/thumb.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/13110/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/13110/medium.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/13110/large.png'), (4, 'a369b1e7-1496-4614-b866-b8d48cce9713', '2021-04-10T05:11:05.000Z', 'Apple locks in users by keeping iMessage iOS-only, Epic says', "Apple apparently thinks it is one of the reasons people don't abandon iOS for Android.", ['Apple Inc', 'AAPL NASDAQ', 'AAPL US'], ['AAPL'], 'other_publication', 'https://www.pocket-lint.com/apps/news/apple/156489-apple-locks-in-users-by-keeping-imessage-ios-only-epic-court-filings-show?utm_campaign=cityfalcon&utm_medium=cityfalcon&utm_source=cityfalcon', ['https://cdn.pocket-lint.com/r/s/1200x630/assets/images/156489-homepage-news-apple-won-t-make-imessage-for-android-to-lock-in-its-users-epic-filings-show-image1-pk7xjh3i4m.jpg'], '-44.5', 'en', 61, 4, 0, 0, 'https://www.cityfalcon.com/news/directory/stocks/apple-inc-aapl', 'pocket-lint.com', 'Pocket-lint', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/4945/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/4945/thumb.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/4945/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/4945/medium.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/4945/large.png'), (5, 'd4988c5b-7cd3-43c9-91a6-2367d4ca2cc5', '2021-04-07T17:30:20.000Z', 'Apple Launches New Find My Network For Third Party Accessory Makers', 'Along with the release of the new iOS 14.5 beta, Apple announced its new Find My Network accessory program for third-party accessory makers.', ['Apple Inc', 'AAPL NASDAQ', 'AAPL US'], ['AAPL'], 'other_publication', 'https://www.iphonehacks.com/2021/04/apple-find-my-network-accessory-makers.html?utm_campaign=cityfalcon&utm_medium=cityfalcon&utm_source=cityfalcon', ['https://www.iphonehacks.com/wp-content/uploads/2021/04/apple-find-my-network.jpg'], '50.0', 'en', 61, 2, 0, 0, 'https://www.cityfalcon.com/news/directory/stocks/apple-inc-aapl', 'iphonehacks.com', 'iPhone Hacks', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/19035/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/19035/thumb.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/19035/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/19035/medium.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/19035/large.png'), (6, 'da949268-0944-4c97-8cca-1691af972f92', '2021-04-07T18:38:01.000Z', 'Apple releases seventh iOS 14.5, watchOS 7.4, and tvOS 14.5 betas', 'Today, Apple released new developer betas of the next versions of iOS, iPadOS, watchOS, and tvOS. The big new feature is that you can unlock your iPhone with an Apple Watch, and more.', ['Apple Inc', 'AAPL NASDAQ', 'AAPL US'], ['AAPL'], 'other_publication', 'https://www.neowin.net/news/apple-releases-seventh-ios-145-watchos-74-and-tvos-145-betas/?utm_campaign=cityfalcon&utm_medium=cityfalcon&utm_source=cityfalcon', ['https://cdn.neow.in/news/images/uploaded/2018/09/1537561292_img_4181_story.jpg'], '32.14', 'en', 61, 2, 0, 0, 'https://www.cityfalcon.com/news/directory/stocks/apple-inc-aapl', 'neowin.net', 'Neowin', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1995/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1995/thumb.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1995/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1995/medium.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1995/large.png'), (7, '87d05ce2-0742-4010-8ac5-fb779cddbcfd', '2021-04-09T21:16:56.000Z', 'Apple decides to skip upcoming Senate antitrust hearing, drawing criticism | AppleInsider', 'U.S. lawmakers are urging Apple to reconsider its decision not to testify in an upcoming Senate subcommittee hearing on antitrust issues in mobile app stores.', ['Apple Inc', 'AAPL NASDAQ', 'AAPL US'], ['AAPL'], 'other_publication', 'https://appleinsider.com/articles/21/04/09/apple-decides-to-skip-upcoming-senate-antitrust-hearing-drawing-criticism?utm_campaign=cityfalcon&utm_medium=cityfalcon&utm_source=cityfalcon', ['https://photos5.appleinsider.com/gallery/41303-80105-US-Capitol-xl.jpg'], '-62.33', 'en', 61, 2, 0, 0, 'https://www.cityfalcon.com/news/directory/stocks/apple-inc-aapl', 'appleinsider.com', 'AppleInsider', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1708/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1708/thumb.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1708/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1708/medium.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/1708/large.png') ... displaying 10 of 82 total bound parameter sets ... (80, '4d6f3d0f-d5fc-44b2-b199-be8de71b35ce', '2021-04-10T16:49:26.000Z', 'Apple Pulls Out of App Store Hearing, Enraging U.S. Senators', '"We strongly urge Apple to reconsider its position and to provide a witness to testify before the Subcommittee in a timely manner."', ['Apple Inc', 'AAPL NASDAQ', 'AAPL US'], ['AAPL'], 'other_publication', 'https://www.iphoneincanada.ca/news/apple-pulls-out-of-app-store-hearing-enraging-u-s-senators/?utm_campaign=cityfalcon&utm_medium=cityfalcon&utm_source=cityfalcon', ['https://cdn.iphoneincanada.ca/wp-content/uploads/2020/06/app-store.jpg'], '-55.9', 'en', 50, 3, 0, 0, 'https://www.cityfalcon.com/news/directory/stocks/apple-inc-aapl', 'iphoneincanada.ca', 'iPhone in Canada', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/20178/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/20178/thumb.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/20178/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/20178/medium.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/20178/large.png'), (81, '5601ab6f-5727-48e8-b966-e628b10a8577', '2021-04-13T09:54:03.000Z', 'Siri spills the beans on Apple’s 4/20 event (BLAZE IT LOL)', 'It’s happening. Probably. Apple is planning to host an event on, April 20, where it might reveal new iPad Pros and (possibly??) its AirTags smart tracker. Take this with a pinch of salt though. This date doesn’t come from an Apple press rel', ['Apple Inc', 'AAPL NASDAQ', 'AAPL US'], ['AAPL'], 'other_publication', 'https://thenextweb.com/news/siri-spills-the-beans-on-apples-4-20-event-blaze-it-lol?utm_campaign=cityfalcon&utm_medium=cityfalcon&utm_source=cityfalcon', ['https://img-cdn.tnwcdn.com/image/plugged?filter_last=1&fit=1280%2C640&url=https%3A%2F%2Fcdn0.tnwcdn.com%2Fwp-content%2Fblogs.dir%2F1%2Ffiles%2F2021%2F04%2Fweed-siri.jpg&signature=4ed1783e579861b6a554b82efd830831'], None, 'en', 50, 0, 0, 0, 'https://www.cityfalcon.com/news/directory/stocks/apple-inc-aapl', 'thenextweb.com', 'The Next Web', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/5382/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/5382/thumb.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/5382/small.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/5382/medium.png', 'https://cityfalconproduction.blob.core.windows.net/autotweetmedia/domains/logos/5382/large.png'))]
(Background on this error at: http://sqlalche.me/e/14/e3q8)
It doesn't make sense as I have 23 columns? The database contain these exact columns with these heading as well so I can't understand why this isn't being pushed.
I am new to mySQL and am happy to provide any data or structure that may shed light on the problem.
Any indication of the problem would be very helpful. Thanks