-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdata.py
More file actions
28 lines (20 loc) · 670 Bytes
/
Copy pathdata.py
File metadata and controls
28 lines (20 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import sqlite3
def get_data():
# Connect to the SQLite database
conn = sqlite3.connect('database.sqlite')
cursor = conn.cursor()
# Retrieve data from the table
table_name = 'your_table'
cursor.execute(f"SELECT * FROM webpages;")
data = cursor.fetchall()
# Specify the output text file
output_file = 'output.txt'
texts = []
# Write the data to the text file
with open(output_file, 'w') as file:
for row in data:
texts.append(row[2])
# Close the database connection
conn.close()
print(f"The contents of the '{table_name}' table have been written to '{output_file}'.")
return texts