Spaces:
Running
Running
Create news_aggregator.db
Browse files- news_aggregator.db +25 -0
news_aggregator.db
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sqlite3
|
2 |
+
|
3 |
+
def create_table():
|
4 |
+
# Connect to SQLite database (it will create the file if it doesn't exist)
|
5 |
+
conn = sqlite3.connect("news_aggregator.db")
|
6 |
+
cursor = conn.cursor()
|
7 |
+
|
8 |
+
# Create articles table
|
9 |
+
cursor.execute('''
|
10 |
+
CREATE TABLE IF NOT EXISTS articles (
|
11 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
12 |
+
title TEXT NOT NULL,
|
13 |
+
description TEXT,
|
14 |
+
link TEXT,
|
15 |
+
topic TEXT,
|
16 |
+
date_published TEXT
|
17 |
+
)
|
18 |
+
''')
|
19 |
+
|
20 |
+
# Commit and close connection
|
21 |
+
conn.commit()
|
22 |
+
conn.close()
|
23 |
+
|
24 |
+
# Run the function to create the table
|
25 |
+
create_table()
|