1241,"操作数应包含 1 列"大熊猫to_sql



我在尝试将数据帧推送到SQL时遇到一个奇怪的SQL错误。我的df只是一个panda数据帧,我正试图将它推送到SQL数据库中。我以前从未遇到过问题,错误消息对问题所在没有任何信息。错误如下:MySQL-Operand应该包含1列尽管我使用的是python。

我的df.head()看起来像这样,要推送的代码和我的错误看起来像这样:

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)

我有23个专栏,这没有意义吗?数据库中也包含这些带有这些标题的精确列,所以我不明白为什么没有推送它。

我是mySQL的新手,很乐意提供任何可能揭示问题的数据或结构。

任何关于这个问题的迹象都会很有帮助。感谢

当我试图将包含列表的列推入不兼容的SQL数据库时,出现了此错误。为了解决这个问题,我简单地将列表转换为字符串,它就起了作用。

不确定这是否会有普遍的帮助,但这就是我解决这个特殊问题的方法。

OP

相关内容

  • 没有找到相关文章