[omaha] Django question
Shawn Hermans
shawnhermans at gmail.com
Fri Jun 15 18:41:49 CEST 2012
I can't think of any other easy solutions to the problem. I looked at the
libanki code and it looks like the database code is spread throughout the
library. I also uses raw SQL rather than something like SQLAlchemy or the
Django ORM. This means it is not trivial to simply use a different database
in place of SQLite. So, I can't really think of an easy solution to the
problem.
Now I can think of a not easy solution. You could fork the libanki code
base and port it over to use SQLAlchemy or Django's ORM. I pulled out the
tables from the source code and it doesn't look too bad. It looks like you
have 5 tables/models. Something to think about at least.
Cheers,
Shawn
create table if not exists col (
id integer primary key,
crt integer not null,
mod integer not null,
scm integer not null,
ver integer not null,
dty integer not null,
usn integer not null,
ls integer not null,
conf text not null,
models text not null,
decks text not null,
dconf text not null,
tags text not null
);
create table if not exists notes (
id integer primary key,
guid text not null,
mid integer not null,
mod integer not null,
usn integer not null,
tags text not null,
flds text not null,
sfld integer not null,
csum integer not null,
flags integer not null,
data text not null
);
create table if not exists cards (
id integer primary key,
nid integer not null,
did integer not null,
ord integer not null,
mod integer not null,
usn integer not null,
type integer not null,
queue integer not null,
due integer not null,
ivl integer not null,
factor integer not null,
reps integer not null,
lapses integer not null,
left integer not null,
odue integer not null,
odid integer not null,
flags integer not null,
data text not null
);
create table if not exists revlog (
id integer primary key,
cid integer not null,
usn integer not null,
ease integer not null,
ivl integer not null,
lastIvl integer not null,
factor integer not null,
time integer not null,
type integer not null
);
create table if not exists graves (
usn integer not null,
oid integer not null,
type integer not null
);
On Fri, Jun 15, 2012 at 11:13 AM, Steve Young <wereapwhatwesow at gmail.com>wrote:
> >
> > ... You might want to look at making deck a session variable.
>
>
> So now I am trying to accomplish just that. deck seems to be an
> instancemethod because when I try to add it to the request.session it gives
> a:
>
> Can't pickle <type 'instancemethod'>: attribute lookup
> __builtin__.instancemethod failed
>
> I found some suggestions about adding __getstate__ and __setstate__ to the
> class to make the instancemethod pickable, but haven't been successful
> with those either. (not 100% sure I am implementing this correctly) The
> only progress I made was using a shell to get a little different pickle
> error:
>
> PicklingError: Can't pickle <class 'sqlalchemy.orm.session.Session'>: it's
> not the same object as sqlalchemy.orm.session.Session
>
> I also tried Shawn's suggestion about encoding deck, with base64.encode and
> base64.encodestring but got TypeErrors with both.
>
> Since this is becoming so difficult, and I don't see much info online when
> searching for these issues, it makes me think I am not taking the correct
> approach. Or maybe I should work some more on the pickling issue... Any
> ideas are welcome. Thanks for everyone's help so far.
>
> Steve
> _______________________________________________
> Omaha Python Users Group mailing list
> Omaha at python.org
> http://mail.python.org/mailman/listinfo/omaha
> http://www.OmahaPython.org
>
More information about the Omaha
mailing list