Регулярные выражения иногда могут быть просто монструозными. Выглядеть это может крайне запутанно. Сами регэкспы и без того история непростая, а когда это длинный паттерн на несколько десятков знаков, разобрать там что-либо становится не просто.
Но на помощь приходит Python и его стремление сделать нашу жизнь проще!
В функциях регулярок можно после паттерна указывать флаги, один из которых позволяет писать паттерны более свободно. А именно, добавлять пробелы и переносы, которые будут игнорированы. В результате мы можем разбить паттерн на строки и добавить комментов.
Чтобы это сработало нужно добавить флаг re.VERBOSE. Пробелы в паттерне теперь следует указывать явно спец символами.
Согласитесь, что даже с именованными группами а таком виде регэкспа выглядит вполне сносно 😉.
#tricks#regex
https://github.com/aio-libs/aiopg
#aiopg is a library for accessing a #PostgreSQL database from the #asyncio (PEP-3156/tulip) framework. It wraps asynchronous features of the Psycopg #database driver.
https://github.com/aio-libs/aiomysql
#aiomysql is a "driver" for accessing a #MySQL database from the #asyncio (PEP-3156/tulip) framework. It depends on and reuses most parts of #PyMySQL . aiomysql tries to be like awesome #aiopg library and preserve same api, look and feel.
Internally aiomysql is copy of PyMySQL, underlying io calls switched to async, basically yield from and asyncio.coroutine added in proper places)). sqlalchemy support ported from aiopg.
http://aiomysql.readthedocs.io/en/latest/sa.html
aiomysql.sa — support for SQLAlchemy functional SQL layer
sqlalchemy support ported from #aiopg, so #api should be very familiar for aiopg user.
While core API provides a core support for access to #MySQL#database, manipulations with raw SQL strings too annoying.
Fortunately we can use excellent SQLAlchemy Core as SQL query builder.
So you can execute SQL #query built by tbl.insert().values(val='abc') or tbl.select() expressions.
#sqlalchemy has rich and very powerful set of SQL construction functions, please read tutorial for full list of available operations.
Also we provide SQL transactions support. Please take a look on SAConnection.begin() method and family.