leapcode / pysqlcipher

Python bindings for SQLCipher
https://leap.se
Other
131 stars 42 forks source link

I can't use sqlcipher to open the database #27

Closed originals-tz closed 4 years ago

originals-tz commented 8 years ago

i use the pysqlcipher to set a password for a database

>>> from pysqlcipher import dbapi2 as sqlite3
>>> c = sqlite3.connect("UserData.db")
>>> com = c.cursor()
>>> passwd = "PRAGMA key='test'"
>>> com.execute(passwd)
<pysqlcipher.dbapi2.Cursor object at 0x7fd676d667a0>
>>> com.execute('''create table hello(id int not null);''')
<pysqlcipher.dbapi2.Cursor object at 0x7fd676d667a0>
>>> com.execute("insert into hello(id) values (3)")
<pysqlcipher.dbapi2.Cursor object at 0x7fd676d667a0>
>>> com.commit()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'pysqlcipher.dbapi2.Cursor' object has no attribute 'commit'
>>> c.commit()
>>> c.close()

but when i want to use the sqlcipher to open the database....

SQLCipher version 3.11.0 2016-02-15 17:29:24
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> PRAGMA key='test';
sqlite> ATTACH DATABASE 'plaintext.db' AS plaintext KEY '';
Error: file is encrypted or is not a database

why?what should i do?can i use the sqlcipher to open the database?

mdomke commented 8 years ago

I was experiencing the same problems. I think it's related to the version of sqlcipher. It worked with sqlcipher 3.8 I think…