Skip to content

Commit

Permalink
Merge pull request #1446 from RustyBower/multi_db_support
Browse files Browse the repository at this point in the history
db: adding multi database support
  • Loading branch information
dgw authored May 12, 2019
2 parents 6e28f98 + 00ebf26 commit adc2fe7
Show file tree
Hide file tree
Showing 4 changed files with 306 additions and 92 deletions.
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ In the source directory (whether cloned or from the tarball) run
bot. Alternately, you can just run the ``sopel.py`` file in the source
directory.

Database Support
----------------
Sopel leverages SQLAlchemy to support the following database types: SQLite,
MySQL, PostgreSQL, MSSQL, Oracle, Firebird, and Sybase. By default Sopel will
use a SQLite database in the current configuration directory, but alternative
databases can be configured with the following config options: ``db_type``,
``db_filename`` (SQLite only), ``db_driver``, ``db_user``, ``db_pass``,
``db_host``, ``db_port``, and ``db_name``. You will need to manually install
any packages (system or ``pip``) needed to make your chosen database work.

Adding modules
--------------
The easiest place to put new modules is in ``~/.sopel/modules``. Some newer
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ requests>=2.0.0,<3.0.0
dnspython<2.0; python_version >= '2.7' and python_version < '3.0'
dnspython<1.16.0; python_version == '3.3'
dnspython<3.0; python_version >= '3.4'
sqlalchemy<1.3; python_version == '3.3'
sqlalchemy<1.4; python_version != '3.3'
32 changes: 31 additions & 1 deletion sopel/config/core_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,38 @@ class CoreSection(StaticSection):
channels = ListAttribute('channels')
"""List of channels for the bot to join when it connects"""

db_type = ChoiceAttribute('db_type', choices=[
'sqlite', 'mysql', 'postgres', 'mssql', 'oracle', 'firebird', 'sybase'], default='sqlite')
"""The type of database to use for Sopel's database.
mysql - pip install mysql-python (Python 2) or pip install mysqlclient (Python 3)
postgres - pip install psycopg2
mssql - pip install pymssql
See https://docs.sqlalchemy.org/en/latest/dialects/ for a full list of dialects"""

db_filename = ValidatedAttribute('db_filename')
"""The filename for Sopel's database."""
"""The filename for Sopel's database. (SQLite only)"""

db_driver = ValidatedAttribute('db_driver')
"""The driver for Sopel's database.
This is optional, but can be specified if user wants to use a different driver
https://docs.sqlalchemy.org/en/latest/core/engines.html"""

db_user = ValidatedAttribute('db_user')
"""The user for Sopel's database."""

db_pass = ValidatedAttribute('db_pass')
"""The password for Sopel's database."""

db_host = ValidatedAttribute('db_host')
"""The host for Sopel's database."""

db_port = ValidatedAttribute('db_port')
"""The port for Sopel's database."""

db_name = ValidatedAttribute('db_name')
"""The name of Sopel's database."""

default_time_format = ValidatedAttribute('default_time_format',
default='%Y-%m-%d - %T%Z')
Expand Down
Loading

0 comments on commit adc2fe7

Please sign in to comment.