added functino to get content from database
This commit is contained in:
@@ -37,6 +37,50 @@
|
||||
" dt.insert(val_dict)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"0 Odense Universitets Hospital søger #Afdelingsc...\n",
|
||||
"1 \"Odense Dänemark, Seaside\" Fotografie als Post...\n",
|
||||
"2 Danimarka’nın Odense takımı bu yaz müthiş bir ...\n",
|
||||
"3 Highlights: SønderjyskE – Odense https://t.co/...\n",
|
||||
"4 “Meta Platforms Inc has halted construction of...\n",
|
||||
" ... \n",
|
||||
"1810 Kunne du tænke dig at være med til at begejstr...\n",
|
||||
"1811 UDEBANEAFSNITTET UDVIDES TIL 1800 PLADSER! \\n\\...\n",
|
||||
"1812 Der er lagt op til fynsk fodboldfest på søndag...\n",
|
||||
"1813 Jeg har i stigende omfang den oplevelse, at @A...\n",
|
||||
"1814 PhD position podning in Odense, Denmark: Impro...\n",
|
||||
"Name: content, Length: 1815, dtype: object"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from database import get_content\n",
|
||||
"\n",
|
||||
"df = get_content()\n",
|
||||
"\n",
|
||||
"df"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df.to_csv('~/Desktop/content.csv')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
||||
+7
-1
@@ -169,4 +169,10 @@ def insert_list(username_list, timestamp_list, content_list):
|
||||
}
|
||||
dt.insert(val_dict)
|
||||
except Exception as e:
|
||||
logging.warning(e)
|
||||
logging.warning(e)
|
||||
|
||||
def get_content():
|
||||
with Data_table() as dt:
|
||||
query = f'SELECT * FROM {dt._name} ORDER BY time DESC '
|
||||
df = pd.read_sql_query(query, dt.con)
|
||||
return df['content']
|
||||
Reference in New Issue
Block a user