Comments (6)
http://docs.sqlalchemy.org/en/rel_1_0/core/type_basics.html#generic-types
SQLAlchemy has the generic SQL type INTERVAL that outputs Python datetime.timedelta. which is what the agate TimeDelta is looking for. INTERVAL is a native data type for Postgres and ORACLE. On other databases INTERVAL it is stored as a date relative to the Unix epoch 1/1/1970. From the above I understand this to mean that the INTERVAL type will only show up in metadata from tables that use the interval type as in Postgres and Oracle. For other databases a date type will show up. In either case the type is covered. The only issue I can see is if a user is using SQLAlchemy as the ORM to create and use their tables outside agate and expect to see an INTERVAL type for a field that they pull against a database that does not support it natively i.e MySQL. They will still get the field it will just be a DATE type. The same goes for pushing data back into a table. The first solution that comes to mind is to create some way for the user to map fields they are using as INTERVAL, so agate-sql can use that SQLAlchemy type instead of DATE. This would not be needed in the Postgres and Oracle cases.
from agate-sql.
Hmmm, I think the "version 1" solution for this is documentation. Let's implement it the naive (database-agnostic) way and then add a note to the docs about db-specific support for TimeDelta. If anybody ever complains we can consider a more robust solution.
from agate-sql.
I agree with the above. I started working on this, but seemed to have hit a snag on the SQLAlchemy side in regards to naming of Interval(INTERVAL). I filed a issue when them:
https://bitbucket.org/zzzeek/sqlalchemy/issues/3571/interval-vs-interval-and-python_type
One option is to special case this, but I would prefer to wait until the above issue is dealt with one way or another.
from agate-sql.
Ugh, just read through that issue. Fortunately I think the variability he describes in how the adapters return types is probably moot four purposes: all numeric types collapse to agate.Number() and all text types collapse to agate.Text().
Based on my reading of your back-and-forth it sounds like the best part forward for INTERVAL is just to hold off until now? Or is there a straightforward way to special case now you know the broader shape of the problem?
from agate-sql.
Longer term I am going to see about getting python_type set for INTERVAL, by submitting a PR to SQLAlchemy. Short term I am thinking a special case. The generic Interval already has python_type set, it is just a matter of intercepting INTERVAL and faking a python_type for it.
from agate-sql.
Sounds good to me! 👍
from agate-sql.
Related Issues (20)
- Tests need to an example of every agate data type
- TimeDelta type doesn't work as expected with sqlite HOT 6
- API docs aren't showing up on RTFD HOT 1
- Add argument to from_sql for SELECT query HOT 2
- Handle non-ascii text values in Python 2 HOT 3
- CREATE statement length constraints are wrong for unicode strings under Py2.7 HOT 2
- Add example usage for query methods HOT 1
- Create an example.py script HOT 1
- DateTime columns can not be stored as DATETIME in sqlite HOT 1
- how to install agate and agatesql in cloud foundry HOT 1
- MSSQL dialect uses BOOLEAN instead of BIT HOT 1
- interesting bits in tarball
- TestSQL.test_to_sql_create_statement_with_schema fails HOT 8
- Release 0.5.6 on PyPI HOT 1
- Test suite showing some ageing cracks HOT 8
- sqlalchemy very outdated HOT 1
- 0.6.0 is tagged to wrong commit HOT 2
- Support "Integer" data types when data has no fractional numbers (floats, decimals) HOT 4
- MySQL needs REPLACE and not INSERT OR REPLACE (though it does use INSERT IGNORE) HOT 1
- Idea to refactor number code HOT 1
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 agate-sql.