42 lines
1.3 KiB
Python
Executable File
42 lines
1.3 KiB
Python
Executable File
import sqlite3
|
|
import datetime
|
|
|
|
db_path = "/home/ubuntu/nanocode/it_automation_enhanced/data/test_articles.db"
|
|
conn = sqlite3.connect(db_path)
|
|
cursor = conn.cursor()
|
|
|
|
cursor.execute('''
|
|
CREATE TABLE IF NOT EXISTS articles (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
title TEXT NOT NULL,
|
|
url TEXT UNIQUE NOT NULL,
|
|
source TEXT NOT NULL,
|
|
category TEXT,
|
|
publish_date TEXT,
|
|
word_count INTEGER DEFAULT 0,
|
|
processed INTEGER DEFAULT 0,
|
|
translation_status INTEGER DEFAULT 0,
|
|
humanizer_status INTEGER DEFAULT 0,
|
|
xhs_status INTEGER DEFAULT 0,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
)
|
|
''')
|
|
|
|
# 插入测试数据
|
|
test_articles = [
|
|
("AI芯片技术的最新突破", "https://example.com/ai-chip", "TestSource", "tech", "2026-03-19", 1200),
|
|
("Python 3.12性能优化指南", "https://example.com/python-optimize", "TestSource", "programming", "2026-03-19", 800),
|
|
("云计算安全最佳实践", "https://example.com/cloud-security", "TestSource", "cloud", "2026-03-19", 1500),
|
|
]
|
|
|
|
cursor.executemany('''
|
|
INSERT OR IGNORE INTO articles
|
|
(title, url, source, category, publish_date, word_count)
|
|
VALUES (?, ?, ?, ?, ?, ?)
|
|
''', test_articles)
|
|
|
|
conn.commit()
|
|
conn.close()
|
|
print(f"测试数据库创建完成: {db_path}")
|
|
print(f"插入 {len(test_articles)} 条测试数据")
|