Advertisement
disk6969

Untitled

Apr 5th, 2024
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. from pathlib import Path
  2. import asyncio, sqlite3
  3. from pyrogram.storage import MemoryStorage, FileStorage
  4.  
  5. async def string_to_sqlite(session_name, string_session):
  6. out_sql = FileStorage(session_name, Path())
  7. in_string = MemoryStorage('temp', string_session)
  8. await out_sql.open(), await in_string.open()
  9. auth_data = in_string.conn.execute('SELECT * FROM sessions').fetchone()
  10. out_sql.conn.execute('DELETE FROM sessions')
  11. out_sql.conn.execute('INSERT or REPLACE INTO sessions VALUES (?, ?, ?, ?, ?, ?, ?)', auth_data)
  12. await out_sql.save(), await out_sql.close(), await in_string.close()
  13. print('Saved string in', out_sql.database)
  14.  
  15. asyncio.run(string_to_sqlite('out_session', 'string_session'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement