英文:
Im getting a getting Error binding parameter 3 - probably unsupported type. How can I fix this table to the right format for sqlite?
问题
在SQLite中创建表格。我认为问题出在缩略图。有人能告诉我要用什么格式来存储jpg链接吗?
CREATE TABLE youtube_video (
id INTEGER PRIMARY KEY AUTOINCREMENT,
published_at TEXT,
title TEXT,
channel_id TEXT,
thumbnails TEXT,  -- 缩略图可能需要另一种格式
channel_title TEXT,
view_count INTEGER,
like_count INTEGER,
dislike_count INTEGER,
favorite_count INTEGER,
duration TEXT,
video_id TEXT,
transcript TEXT
);
在PyCharm中的代码以向SQLite表格添加数据。cursor.execute(insert_query, ( 
                        cursor.execute(insert_query, (
                            snippet['publishedAt'],
                            snippet['title'],
                            snippet['channelId'],
                            snippet['thumbnails'],  -- 缩略图可能需要更改格式
                            snippet['channelTitle'],
                            statistics.get('viewCount', 0),
                            statistics.get('likeCount', 0),
                            statistics.get('dislikeCount', 0),
                            statistics.get('favoriteCount', 0),
                            content_details['duration'],
                            video_id,
                            transcript,
                        ))
                        ))
我遇到了一个错误,参数绑定错误,可能是不支持的数据类型。如何将这个表格调整为适合SQLite的正确格式?
英文:
table in sqlite. I think its the tumbnails. Can someone let me know what to use for a jpg link
CREATE TABLE youtube_video (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    published_at TEXT,
    title TEXT,
    channel_id TEXT,
    thumbnails TEXT,
    channel_title TEXT,
    view_count INTEGER,
    like_count INTEGER,
    dislike_count INTEGER,
    favorite_count INTEGER,
    duration TEXT,
    video_id TEXT,
    transcript TEXT
);
code in pycharm to add data to sqlite table. cursor.execute(insert_query, (
                            cursor.execute(insert_query, (
                                snippet['publishedAt'],
                                snippet['title'],
                                snippet['channelId'],
                                snippet['thumbnails'],
                                snippet['channelTitle'],
                                statistics.get('viewCount', 0),
                                statistics.get('likeCount', 0),
                                statistics.get('dislikeCount', 0),
                                statistics.get('favoriteCount', 0),
                                content_details['duration'],
                                video_id,
                                transcript,
                            ))
                            ))
Im getting a getting Error binding parameter 3 - probably unsupported type. How can I fix this table to the right format for sqlite?
答案1
得分: 0
像下面这样应该能解决问题:
    cursor.execute(insert_query, (
                                    str(snippet['publishedAt']),
                                    str(snippet['title']),
                                    str(snippet['channelId']),
                                    str(snippet['thumbnails']),
                                    str(snippet['channelTitle']),
                                    statistics.get('viewCount', 0),
                                    statistics.get('likeCount', 0),
                                    statistics.get('dislikeCount', 0),
                                    statistics.get('favoriteCount', 0),
                                    content_details['duration'],
                                    video_id,
                                    transcript,
                                ))
                                ))
英文:
Something like below should sort it out:
cursor.execute(insert_query, (
                                str(snippet['publishedAt']),
                                str(snippet['title']),
                                str(snippet['channelId']),
                                str(snippet['thumbnails']),
                                str(snippet['channelTitle']),
                                statistics.get('viewCount', 0),
                                statistics.get('likeCount', 0),
                                statistics.get('dislikeCount', 0),
                                statistics.get('favoriteCount', 0),
                                content_details['duration'],
                                video_id,
                                transcript,
                            ))
                            ))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论