All Projects → tulir → telethon-session-sqlalchemy

tulir / telethon-session-sqlalchemy

Licence: MIT License
SQLAlchemy backend for Telethon session storage

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to telethon-session-sqlalchemy

pykorm
A python 🐍 kubernetes ☸️ ORM 🚀. Very useful when writing operators for your CRDs with Kopf.
Stars: ✭ 56 (+64.71%)
Mutual labels:  sqlalchemy
nebulo
Instant GraphQL API for PostgreSQL and SQLAlchemy
Stars: ✭ 74 (+117.65%)
Mutual labels:  sqlalchemy
execute-engine
基于Ansible API的任务执行引擎,支持adhoc和playbook两种任务的执行
Stars: ✭ 18 (-47.06%)
Mutual labels:  sqlalchemy
fastapi-starter
A FastAPI based low code starter: Async SQLAlchemy, Postgres, React-Admin, pytest and cypress
Stars: ✭ 97 (+185.29%)
Mutual labels:  sqlalchemy
flaskbooks
A very light social network & RESTful API for sharing books using flask!
Stars: ✭ 19 (-44.12%)
Mutual labels:  sqlalchemy
PythonTwitchBotFramework
asynchronous twitchbot framework made in pure python
Stars: ✭ 78 (+129.41%)
Mutual labels:  sqlalchemy
tgcf
The ultimate tool to automate custom telegram message forwarding. Live-syncer, Auto-poster, backup-bot, cloner, chat-forwarder, duplicator, ... Call it whatever you like! tgcf can fulfill your custom needs.
Stars: ✭ 378 (+1011.76%)
Mutual labels:  telethon
mnemosyne
Session management service with RPC API based on protobuf.
Stars: ✭ 15 (-55.88%)
Mutual labels:  session
dvhb-hybrid
A package to mix django and asyncio in one application
Stars: ✭ 45 (+32.35%)
Mutual labels:  sqlalchemy
Agile-Server
A simple, fast, complete Node.js server solution, based on KOA. 简单快速的 、性能强劲的、功能齐全的 node 服务器解决方案合集,基于 KOA。
Stars: ✭ 24 (-29.41%)
Mutual labels:  session
mathesar
Web application providing an intuitive user experience to databases.
Stars: ✭ 95 (+179.41%)
Mutual labels:  sqlalchemy
laminas-session
Object-oriented interface to PHP sessions and storage
Stars: ✭ 35 (+2.94%)
Mutual labels:  session
carry
Python ETL(Extract-Transform-Load) tool / Data migration tool
Stars: ✭ 115 (+238.24%)
Mutual labels:  sqlalchemy
bonobo-sqlalchemy
PREVIEW - SQL databases in Bonobo, using sqlalchemy
Stars: ✭ 23 (-32.35%)
Mutual labels:  sqlalchemy
TelethonBot
Simple base for a telethon bot!
Stars: ✭ 54 (+58.82%)
Mutual labels:  telethon
FinanceCenter
Fetching Financial Data (US/China)
Stars: ✭ 26 (-23.53%)
Mutual labels:  sqlalchemy
keycloak-session-restrictor
Simple event-listener for Keycloak which restricts the current user sessions to one (last one wins) only. Demo purposes only!
Stars: ✭ 48 (+41.18%)
Mutual labels:  session
Awesome-Telegram-OSINT
📚 A Curated List of Awesome Telegram OSINT Tools, Sites & Resources
Stars: ✭ 577 (+1597.06%)
Mutual labels:  telethon
UniBorg
Pluggable Telegram bot and userbot based on Telethon
Stars: ✭ 196 (+476.47%)
Mutual labels:  telethon
OSAPI
👋 OSAPI 是依靠通用性后台管理平台搭建的API管理平台,基于 vue3、Nestjs 技术栈实现,包含 RBAC 角色权限模块、数据展示、编辑等模块。
Stars: ✭ 32 (-5.88%)
Mutual labels:  session

Telethon SQLAlchemy session

A Telethon session storage implementation backed by SQLAlchemy.

Installation

telethon-session-sqlalchemy @ PyPI

pip install telethon-session-sqlalchemy

Usage

This session implementation can store multiple Sessions in the same database, but to do this, each session instance needs to have access to the same models and database session.

To get started, you need to create an AlchemySessionContainer which will contain that shared data. The simplest way to use AlchemySessionContainer is to simply pass it the database URL:

from alchemysession import AlchemySessionContainer
container = AlchemySessionContainer('postgres://user:pass@localhost/telethon')

If you already have SQLAlchemy set up for your own project, you can also pass the engine separately:

my_sqlalchemy_engine = sqlalchemy.create_engine('...')
container = AlchemySessionContainer(engine=my_sqlalchemy_engine)

By default, the session container will manage table creation/schema updates/etc automatically. If you want to manage everything yourself, you can pass your SQLAlchemy Session and declarative_base instances and set manage_tables to False:

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import orm
import sqlalchemy
...
session_factory = orm.sessionmaker(bind=my_sqlalchemy_engine)
session = session_factory()
my_base = declarative_base()
...
container = AlchemySessionContainer(
    session=session, table_base=my_base, manage_tables=False
)

You always need to provide either engine or session to the container. If you set manage_tables=False and provide a session, engine is not needed. In any other case, engine is always required.

After you have your AlchemySessionContainer instance created, you can create new sessions by calling new_session:

session = container.new_session('some session id')
client = TelegramClient(session)

where some session id is an unique identifier for the session.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].