pyautomail.storage
pyautomail.storage.model
This module contains the classes that are used to store the data in the database
- class Process(**kwargs)[source]
Bases:
Base
This class is used to store the processes of the emails in the database the table name is process
Every time you register a contact list to send emails to it, a process will be created and stored in the database
Every process has a list of records which contains the information of the emails that will be sent
The process has a status which can be chosen from STATUSES
- records
the records of the process
- Type:
automail.storage.model.Record
- STATUSES = [('created', 'Created'), ('in progress', 'In progress'), ('paused', 'Paused'), ('finished', 'Finished')]
the possible statuses of the process
- Type:
list
- id
the id of the process
- Type:
int
- release_date
the date of the release of the process
- Type:
datetime.date
- sender
the email address of the sender
- Type:
str
- status
the status of the process it can be choose from STATUSES
- Type:
str
- subject
the subject of the email
- Type:
str
- temp_file
the path to the template file
- Type:
str
- title
the title of the process
- Type:
str
- class Record(**kwargs)[source]
Bases:
Base
This class is used to store the records of the processes in the database table ‘record’
Every record contains the information of one email
- STATUSES = [('unsent', 'Unsent'), ('sent', 'Sent')]
the possible statuses of the record
- Type:
list
- attachment_path
the path to the attachment file
- Type:
str
- data
the custom data of the email a string of json
- Type:
str
- id
the id of the record
- Type:
int
- process
the process of the record
- Type:
pyautomail.storage.database.Process
- process_id
the id of the process which this record belongs to
- Type:
int
- receiver
the email address of the receiver
- Type:
str
- status
the status of the record it can be choose from STATUSES
- Type:
str
pyautomail.storage.util
- create_tables(engine)[source]
create tables in database
- Parameters:
engine (sqlalchemy.engine.base.Engine) – an engine from database
- Return type:
None
Examples
>>> create_tables(engine)
- get_session()[source]
get a session from database
- Returns:
session (sqlalchemy.orm.session.Session) – a session from database
engine (sqlalchemy.engine.base.Engine) – an engine from database
Examples
>>> get_session() (<sqlalchemy.orm.session.Session object at 0x0000020F4F6F6F98>, <sqlalchemy.engine.base.Engine object at 0x0000020F4F6F6F28>)
- register_new_process(title, subject, email, template, contact_list, custom_pdf, attachment, custom_pdf_dir)[source]
register a new process in database
- Parameters:
title (str) – title of the process
subject (str) – subject of the process
email (str) – email of the sender
template (str) – path to the template
contact_list (str) – path to the contact list
custom_pdf (bool) – if True, convert the contact list to pdf
attachment (str) – path to the attachment
custom_pdf_dir (str) – path to the custom pdf
- Return type:
None
Examples
>>> register_new_process(title="test", subject="test", email="test", template="test", contact_list="test", custom_pdf=False, attachment=None, custom_pdf_dir=None)