I've no idea how pysqlite handles Windows-style filepaths. Your first step
would be to figure this out for us, using the "sqlite3" module directly:
import sqlite3
conn = sqlite3.connect('C:\Users\<username>\Desktop\snapshot.db')
cursor = conn.cursor()
cursor.execute("select * from mytable")
The URL passed to create_engine() expects forwards slashes. You may need to
produce a sqlalchemy.url.URL() object programatically, or we may need to add
some compatibility features.
On Nov 21, 2012, at 11:32 PM, Patrick Olsen wrote:
> Hello,
>
> I'm using the following code and seem to be getting an error. When I
> duplicete this code and use it against another database it works fine. I can
> also open this snapshot.db with Firefox SQL Manager so I don't believe the
> error message is correct when it says, "file is encrypted or is not a
> database". It's a database.
>
>
> sqlalchemy.exc.DatabaseError: (DatabaseError) file is encrypted or is not a
> database u'SELECT cloud_entry.resource_id AS cloud_entry_resource_id,
> cloud_entry.filename AS cloud_entry_filename \nFROM cl ... (truncated)
>
> Here is the code I am using....
>
> from sqlalchemy import *
> from sqlalchemy.ext.declarative import *
> from sqlalchemy.orm import *
>
> #Don't forget to change the <username>
> engine = create_engine('sqlite:///C:\Users\<username>\Desktop\snapshot.db',
> echo=True)
> Base = declarative_base()
>
> class Snapshot(Base):
> """"""
> __tablename__ = "cloud_entry"
> resource_id = Column(String, primary_key=True)
> filename = Column(String)
>
> #This creates a session
> Session = sessionmaker(bind=engine)
> session = Session()
>
> #test print
> res = session.query(Snapshot).all()
> for cloud_entry in res:
> print cloud_entry.resource_id
> print cloud_entry.filename
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sqlalchemy/-/CRopAaoJ7pYJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.