mirror of
https://github.com/Sheldan/Sissi.git
synced 2026-01-26 19:21:43 +00:00
[SIS-xxx] adding sync of starboard posts and quotes, including migration script
This commit is contained in:
26
python/tools/migrations/quotes-starboard-import/main.py
Normal file
26
python/tools/migrations/quotes-starboard-import/main.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import sqlalchemy as db
|
||||
import os
|
||||
from starboard_loader import load_all_starboard_posts
|
||||
from post_loader import enrich_posts
|
||||
from quote_importer import import_quotes, fix_quote_created
|
||||
|
||||
db_host = os.getenv('DB_HOST')
|
||||
db_port = os.getenv('DB_PORT')
|
||||
db_database = os.getenv('DB_NAME')
|
||||
db_user = os.getenv('DB_USER')
|
||||
db_password = os.getenv('DB_PASS')
|
||||
|
||||
engine = db.create_engine('postgresql://%s:%s@%s:%s/%s' % (db_user, db_password, db_host, db_port, db_database))
|
||||
|
||||
with engine.connect() as con:
|
||||
posts = load_all_starboard_posts(con)
|
||||
print(posts)
|
||||
print(f'Loaded {len(posts)}')
|
||||
enriched_posts = enrich_posts(posts)
|
||||
print(f'Enriched posts')
|
||||
import_quotes(enriched_posts, con)
|
||||
print(f'Done storing quotes')
|
||||
con.commit()
|
||||
fix_quote_created(enriched_posts, con)
|
||||
con.commit()
|
||||
print('Done.')
|
||||
Reference in New Issue
Block a user