basic export script working
This commit is contained in:
parent
33348200af
commit
afff6ad230
17
main.py
17
main.py
@ -15,12 +15,17 @@ cursor = db.cursor()
|
|||||||
cursor.execute('SELECT * FROM spip_articles')
|
cursor.execute('SELECT * FROM spip_articles')
|
||||||
|
|
||||||
# Loop through the results and format data into Markdown files
|
# Loop through the results and format data into Markdown files
|
||||||
for row in cursor.fetchall():
|
# Columns:
|
||||||
front_matter = {'title': row[1], 'date': row[2]} # Example front matter fields
|
# 2: titre
|
||||||
markdown_content = f'---\n{yaml.dump(front_matter)}---\n{row[3]}' # Example Markdown content
|
# 7: texte
|
||||||
file_path = f'{row[0]}.md' # Example file path
|
# 9: date
|
||||||
with open(file_path, 'w') as f:
|
# for row in cursor.fetchall():
|
||||||
f.write(markdown_content)
|
for row in cursor.fetchmany(5):
|
||||||
|
frontmatter = {'title': row[2], 'date': row[9]}
|
||||||
|
content = f'---\n{yaml.dump(frontmatter)}---\n{row[7]}'
|
||||||
|
path = f'markdown/{row[2]}.md'
|
||||||
|
with open(path, 'w') as f:
|
||||||
|
f.write(content)
|
||||||
|
|
||||||
# Close the database connection
|
# Close the database connection
|
||||||
db.close()
|
db.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user