Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db: adding multi database support #1446

Merged
merged 2 commits into from
May 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
dgw marked this conversation as resolved.
Show resolved Hide resolved
"""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
dgw marked this conversation as resolved.
Show resolved Hide resolved

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
Exirel marked this conversation as resolved.
Show resolved Hide resolved
https://docs.sqlalchemy.org/en/latest/core/engines.html"""
Exirel marked this conversation as resolved.
Show resolved Hide resolved

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