I have some tools that may be interesting for others and put these in
a package in the cheese shop: http://pypi.python.org/pypi/sqmediumlite/2.1.0
There is documentation in there. I may revert to this If issues turn
up in this list where it can be applied.
I think a recent issue about 'strict transactions' is resolved with
apswdbapi2.
Best regards, Edzard Pasma
On 09/12/11 09:26, E.Pasma wrote:
> http://pypi.python.org/pypi/sqmediumlite/2.1.0
Is there anything I can do to apsw to make things easier?
For example you really shouldn't need to include a complete copy of the
APSW shell. There is also a C accelerated version of format_sql_value.
If you want a pure python version that is complete then look for the
source version just before the C version was introduced.
For the row factory stuff the approach of using a wrapped dict for each
row is very memory intensive. A better approach is to create a class
using slots and then uses instances for each row. The difficulty of doing
that from C code is why I haven't done it myself yet, but perhaps I should
revisit. (This is what the standard library named tuple implementation does.)
How complete is the DBAPI wrapper? If it is "perfect" then I'd be happy
to point to it from the apsw documentation.
Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iEYEARECAAYFAk7pjpEACgkQmOOfHg372QT4qQCeMbVaH5BaavvFnVOpoxN2obLP
U5MAnR1XS9vf/k17UxwH7fgZn1q92QfM
=Gd5F
-----END PGP SIGNATURE-----
On 15 dec 2011, om 07:07 Roger Binns has written:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 09/12/11 09:26, E.Pasma wrote:
>> http://pypi.python.org/pypi/sqmediumlite/2.1.0
>
> Is there anything I can do to apsw to make things easier?
> For example you really shouldn't need to include a complete copy of
> the
> APSW shell. There is also a C accelerated version of
> format_sql_value.
> If you want a pure python version that is complete then look for the
> source version just before the C version was introduced.
>
Thanks for this tip. That will fix the dump of binary values.
The package contains multiple tools and the included copy of the shell
is used only for the network connection tool, not for apswdbapi2.
Apswdbapi2 uses the unmodified, true APSW shell.
> For the row factory stuff the approach of using a wrapped dict for
> each
> row is very memory intensive. A better approach is to create a class
> using slots and then uses instances for each row. The difficulty of
> doing
> that from C code is why I haven't done it myself yet, but perhaps I
> should
> revisit. (This is what the standard library named tuple
> implementation does.)
>
It is not clear to me yet how you can use slots here. As you say, you
need a class definition to map the column names to the slots. This
class differs per query and I do not see when/where to define it.
Possibly once in a pre-fetch stage?
> How complete is the DBAPI wrapper? If it is "perfect" then I'd be
> happy
> to point to it from the apsw documentation.
>
Wiith respect to the DB-API2, it lacks the Date/Time constructors:
Date, DateFromTicks, DateTime, The DB-API invites programmers to use
these contructors to pass DATE values into queries. Having no DATE
type in the database that is useles. So I think it is better to leave
them out.
(This may be different in the standard Python sqlite3 module which has
the feature of adapters and converters)
Apswdbap2 also lacks the Binary constructor. This is a different case
as its instances can be stored in the database as BLOB. It is not
essential but should be added.
Finally the data type objects (STRING, NUMBER etc) are omitted. These
are not in the standard sqlite3 module either. The DB-API2 expects
these types in cursor descriptions. But column data types are not
available in SQLite.
I am afraid that the module does not yet pass the criteria for a place
in the APSW documentation. Could we otherwise add a page to the WIKI
where to mention tools like this?
Edzard
On 15/12/11 16:25, E.Pasma wrote:
> I was afraid apswdbapi2 would be considered a disobedience to the
> mission of APSW. I'm relieved.
I have no intention of making APSW dbapi compatible, but I'm happy to make
pieces where it doesn't matter do things the dbapi way. For example
method names are the same as dbapi2.
And pointing folks to a wrapper that makes it dbapi compatible is just fine.
>> There is also a C accelerated version of format_sql_value.
>>
> Thanks for this tip. That will fix the dump of binary values.
It will also fix strings that have embedded nulls in them.
> It is not clear to me yet how you can use slots here. As you say, you
> need a class definition to map the column names to the slots. This
> class differs per query and I do not see when/where to define it.
> Possibly once in a pre-fetch stage?
It would be best defined on demand on the first result row of a query.
> So I think it is better to leave them out.
At which point you end up back with APSW again - expose SQLite exactly as
it is, rather than pretending it is something different.
> Could we otherwise add a page to the WIKI where to mention tools like
> this?
No one reads the wiki! I don't get any email queries about it either.
Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iEYEARECAAYFAk7qmNcACgkQmOOfHg372QS9yQCgh4FTaRjYKM8L2ePwdl5Fo9fq
vkgAnRdV7VK3ycN3pvlUZdHZARsIzxwG
=9obH
-----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 15/12/11 16:25, E.Pasma wrote:I was afraid apswdbapi2 would be considered a disobedience to themission of APSW. I'm relieved.
I have no intention of making APSW dbapi compatible, but I'm happy to make
pieces where it doesn't matter do things the dbapi way. For example
method names are the same as dbapi2.
It is not clear to me yet how you can use slots here. As you say, youneed a class definition to map the column names to the slots. Thisclass differs per query and I do not see when/where to define it.Possibly once in a pre-fetch stage?
It would be best defined on demand on the first result row of a query.
So I think it is better to leave them out.
At which point you end up back with APSW again - expose SQLite exactly as
it is, rather than pretending it is something different.
Could we otherwise add a page to the WIKI where to mention tools likethis?
No one reads the wiki! I don't get any email queries about it either.
On 16/12/11 05:43, E.Pasma wrote:
> What I am after is an extra level in the error hierarchy, between the
> top level error and the SQLite errors. This would allow to catch for
> instance a BusyError as an OperationalError,
Let me think about it.
http://code.google.com/p/apsw/issues/detail?id=125
> Then you need a reference to the current row class, probably as a
> cursor attribute. And if that would be reset before each new query,
> then things become easy.
This is trivial to do in the C code. Or by changing the row tracer api.
More thought required.
> The page "/Setting up a Windows 7 64 bit build environment" /must
> become relevant though.
That is actually for my benefit. It was ridiculously difficult to get
everything working correctly.
Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iEYEARECAAYFAk7tVLAACgkQmOOfHg372QT+TgCgwKoS2mI8ko/C/p5CGIgqxzux
50gAnjYeJJGoAcQr7ITzpfLNF565P3gV
=WfMn
-----END PGP SIGNATURE-----