sprin / pg-discuss

A comment system backend in Python with PostgreSQL
http://pg-discuss.sprin.io/
10 stars 1 forks source link

Support for mysql driver #21

Closed avionbg closed 8 years ago

avionbg commented 8 years ago

Hi, I was wondering how difficult would be to support the mysql connector having in mind that the code is based on SQLAlchemy. Are there any postgre specific optimizations in the code (and where) ?

sprin commented 8 years ago

Here's a quick overview of the DB design choices: http://pg-discuss.sprin.io/en/latest/internals/database.html

If you really want to use this comment system with MySQL/MariaDB, I would recommend forking the project. Depending on which extensions you want to use, the changes could be relatively shallow. On the other hand, certain extensions would need to be rewritten. The entire codebase is tiny, so it shoudn't be a gargantuan task either way. I would be interested in undertaking this for pay.

There are two reasons why I am not eager to support MySQL alongside PostgreSQL:

There are two important PostgreSQL features used: JSONB (JSON column type) and CTEs (Common Table Expressions).

JSONB is used pretty ubiquitously as an efficient arbitrary key-value store. It allows extensions to create new keys without modifying the schema. Many extensions use the custom_json column on the comment table in this way: https://github.com/sprin/pg-discuss/search?utf8=%E2%9C%93&q=custom_json

CTEs are not as widely used. Currently they are only used as an optimization in the voting extension. Both an insert and an update can be combined into a single statement to avoid multiple round trips to the database. To record a vote, only a single trip to the database is needed: https://github.com/sprin/pg-discuss/blob/5256915bfe2ac54d5f1e74e43b704101011c8c3a/pg_discuss/queries.py#L273 https://github.com/sprin/pg-discuss/blob/9c4fdd5b2b3e7256ae1e798170db0c4b76185df9/blessed_extensions/voting.py#L30

sprin commented 8 years ago

Closing for now because there's currently not enough incentive on my part.

Thanks for the interest!