Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pathlib import Path
- import asyncio, sqlite3
- from pyrogram.storage import MemoryStorage, FileStorage
- async def string_to_sqlite(session_name, string_session):
- out_sql = FileStorage(session_name, Path())
- in_string = MemoryStorage('temp', string_session)
- await out_sql.open(), await in_string.open()
- auth_data = in_string.conn.execute('SELECT * FROM sessions').fetchone()
- out_sql.conn.execute('DELETE FROM sessions')
- out_sql.conn.execute('INSERT or REPLACE INTO sessions VALUES (?, ?, ?, ?, ?, ?, ?)', auth_data)
- await out_sql.save(), await out_sql.close(), await in_string.close()
- print('Saved string in', out_sql.database)
- asyncio.run(string_to_sqlite('out_session', 'string_session'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement