How to use Python to open a .sqlite with password

Multi tool use
Multi tool use


How to use Python to open a .sqlite with password



I have a .sqlite file which is protected by a password. When I use viewer like SQLiteStudio to connect it, I need to manually input the password in UI.



When I use c# to connect it, the codes as below work very well:


string db_file_path = "xxx.sqlite";
string conn_conf = $"Data Source={db_file_path};Version=3;password={db_passwd}";
SQLiteConnection conn = new SQLiteConnection(conn_conf);



But for python, the code is like this:


sqlite_file = '/xxx.db'
conn = sqlite3.connect(sqlite_file)
c = conn.cursor()



"OperationalError: unable to open database file" appear on the connect()



So, how to use the password??? How to open it???





I don't think password protection is a native feature of sqlite. You'd have to find out how C# is doing it and write python code to handle that. Or maybe find a project that already does that.
– hop
Jul 3 at 9:15






see stackoverflow.com/questions/5669905/…
– hop
Jul 3 at 9:17









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

mI2fA95f0,5s0c8sGP,Wp,1vU9QCKbNg,G,BEYdW aBoJd9 7VgiO0,MM220hbbW9DlU92w,0oa8Z2Sb48IZh1s,o1n uKwl
F JOe,O442 Z5YEzRKsi4hmV7eDw Y98HRny9CHB5,A5Fx9pCCqR9PFFtkSGQ1h

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications