forked from ftmdeveloperz/StringSessionBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers_sql.py
More file actions
35 lines (25 loc) · 852 Bytes
/
users_sql.py
File metadata and controls
35 lines (25 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from env import DATABASE_URL
from sqlalchemy import Column, BigInteger
if DATABASE_URL !="":
from StringSessionBot.database import BASE, SESSION
else:
BASE = object
class Users(BASE):
__tablename__ = "users"
__table_args__ = {'extend_existing': True}
user_id = Column(BigInteger, primary_key=True)
def __init__(self, user_id, channels=None):
if DATABASE_URL == "":
return
self.user_id = user_id
self.channels = channels
# def __repr__(self):
# return "<User {} {} {} ({})>".format(self.thumbnail, self.thumbnail_status, self.video_to, self.user_id)
if DATABASE_URL !="":
Users.__table__.create(checkfirst=True)
async def num_users():
if DATABASE_URL !="":
try:
return SESSION.query(Users).count()
finally:
SESSION.close()