We need to create a virtual env for our app to run in: More Here Run this command in whatever folder you want to create your venv folder
python -m venv ./venv
SELECT table, | |
formatReadableSize(sum(bytes)) as size, | |
min(min_date) as min_date, | |
max(max_date) as max_date | |
FROM system.parts | |
WHERE active | |
GROUP BY table |
import luigi | |
from luigi.contrib import ftp | |
class UploadFileToFTP(luigi.Task): | |
file_path = luigi.Parameter() | |
delete_file = luigi.BoolParameter(default=False) | |
def output(self): | |
return ftp.RemoteTarget('ftp.example.com', self.file_path) |
# To list installed distributions | |
wsl -l | |
wsl --list | |
# To list installed distributions along with its running status and wsl config being 1 or 2 | |
wsl -l --verbose | |
wsl -l -v | |
# To run a specific distro | |
wsl -d distro_name |
# change to postgres user and open psql prompt | |
sudo -u postgres psql postgres | |
# list databases | |
postgres=# \l | |
# list roles | |
postgres=# \du | |
# create role |
import luigi | |
import time | |
class TimeTaskMixin(object): | |
''' | |
A mixin that when added to a luigi task, will print out | |
the tasks execution time to standard out, when the task is | |
finished | |
''' | |
@luigi.Task.event_handler(luigi.Event.PROCESSING_TIME) |
def sync_events(): | |
ts = get_last_event_ts() | |
if not ts: | |
ts = datetime.now() | |
while True: | |
ts = add_new_events_to_notify(ts) | |
if not ts: | |
ts = get_last_event_ts() | |
sleep(DB_PROCESS_TIMEOUT) |
class FailedEvents(Base): | |
__tablename__ = 'failed_events' | |
event_id = Column(Integer, primary_key=True) | |
delivered = Column(Boolean) | |
def get_last_event_ts() -> datetime: | |
session = Session() | |
max_ts = session.query(func.max(TasksEvents.ts)).\ | |
select_from(TasksEvents, FailedEvents).\ | |
filter(TasksEvents.id == FailedEvents.event_id).\ |
def make_conn(): | |
return sqlite3.connect(LUIGI_HISTORY_DBPATH) | |
def load_new_luigi_events(time: str) -> List[Dict]: | |
""" Load luigi events which happened after some time point""" | |
cursor = make_conn().cursor() | |
cursor.execute(SQL, [time]) | |
cols = [col[0] for col in cursor.description] | |
return [dict(zip(cols, row)) for row in cursor.fetchall()] |
We need to create a virtual env for our app to run in: More Here Run this command in whatever folder you want to create your venv folder
python -m venv ./venv
In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc
Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server
Use this link and get $10 free. Just select the $5 plan unless this a production app.