Comments (5)
A cursor factory overrides the row trace. Heck it overrides the cursor! The best way to think of it is that row trace works with the builtin cursor, while a cursor factory takes over all cursor duties and does whatever it wants however it wants.
If you look closely you'll notice the cursor factory is the one providing the execute and executemany methods.
It is documented as doing conversion in and out:
Provides cursors that can convert objects into one of the types supported by SQLite, or back from SQLite
from apsw.
It is documented as doing conversion in and out:
Provides cursors that can convert objects into one of the types supported by SQLite, or back from SQLite
Indeed, but I presumed (through the power of "motivated reasoning" (aka: wishful thinking)) that meant different methods handled different components. Specifically:
register_adapter - Registers a callable that converts from klass to one of the supported SQLite types
- to SQLite
register_converter - Registers a callable that converts from a SQLite value
- from SQLite
I parse that as: if I set an adapter, that's writing to SQLite. My naive interpretation then is that the rowtrace will continue to handle the reading from SQLite. Evidently this is wrong, but you can hopefully see how the docs foster this misunderstanding.
A cursor factory overrides the row trace.
To my (very) lay mind, these are basically the same thing. After all, I point the rowtrace
at a cursor factory. Obviously I'm wrong there too; I suppose my point here is that the learning curve behind apsw
is deceptively steep.
from apsw.
row tracing is for row tracing. The types converter is for converting types.
I've just double checked and none of the doc for row tracing suggests using it for type conversion. (Testing is a good use case.) Adding doc clarification and pointers.
from apsw.
row tracing is for row tracing.
As a tautology, that presumes the user knows what "row tracing" is. https://rogerbinns.github.io/apsw/execution.html#row-tracer in turn is predicated on knowing what a "tracer" is - the docs don't really go into detail beyond saying they're useful for testing/diagnostics.
I actually got my rowtrace factory from your docs:
def _factory_to_dict_apsw(cursor, row):
# From: https://rogerbinns.github.io/apsw/tips.html#cursors
return {k[0]: row[i] for i, k in enumerate(cursor.getdescription())}
I see it has gone now. Unfortunately this means there's now no documentation for how to achieve this (or maybe I'm missing it).
from apsw.
That example is showing how to return a dict instead of a tuple. The whole page it came from is about the execution model. You are right that there is a learning curve going from nothing to understanding SQLite's execution model to understanding how APSW simplifies and wraps that. The example/tour page tries to help. I often feel the same way when trying a completely new package with new concepts and ways of doing things. It always takes me a bit of work for it to click together.
Unfortunately this means there's now no documentation for how to achieve this (or maybe I'm missing it).
By "it" I believe you mean converting types going into the database and coming back out. The example section does show both directions. I added datetime in a commit yesterday which will be in the next release which should help your specific case.
from apsw.
Related Issues (20)
- Implement Unicode TR-29 and TR-14 HOT 1
- error: static declaration of ‘PyLong_AsInt’ in Python 3.13+ HOT 3
- Switch to cosign for signing
- Incorrect values in `colUsed` HOT 2
- Update to Unicode 16.0 when released September 2024 HOT 2
- connection.set_row_trace - excepts; Connection.setrowtrace works HOT 4
- Datetimes into sqlite via APSW HOT 1
- Revise logging levels
- query execution row and time limits HOT 1
- Support subtypes in functions
- Don't cache pragmas
- con.pragma can't accept blobs HOT 1
- Update Connection.pragma with schema parameter
- Implement SQLITE_FCNTL_VFSNAME
- VFS xRandomness errors need to be unraisable HOT 1
- apsw.ext.query_info should find bound parameters
- Comprehensive dump module
- Remove RTD fonts for source build
- How do I get second connection to see table immediately after first connection creates it? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apsw.