[sqlalchemy] calling LENGTH() in SQLite?

2019-07-29 Thread James Hartley
Perhaps I have been up too many hours, but my syntax foo is fizzling. Given the following class, I want to compute the string length of "position" instead of storing it as another attribute which can get out of sync. eg. class Position(Base): __tablename__ = 'position' id =

[sqlalchemy] confirming SQLite pragma settings?

2015-11-08 Thread James Hartley
I have successfully installed SQLAlchemy 1.0.9, & can enable foreign key constraint support on each connection by hooking the event as specified in the following: http://docs.sqlalchemy.org/en/latest/dialects/sqlite.html SQLite also allows pragma settings to be queried in the command-line shell

[sqlalchemy] translating many-to-many relationship from CSV to database?

2014-10-13 Thread James Hartley
I have a CSV file with lots of redundant data which models many-to-many relationships. I'm needing to scrub the data as it is inserted into the database littered with unique constraints. Is there a way to insert the data once without querying for each object before inserting? I'm sure this is a

Re: [sqlalchemy] views declarative?

2013-04-19 Thread James Hartley
On Wed, Apr 17, 2013 at 2:59 PM, Michael Bayer mike...@zzzcomputing.comwrote: James Hartley jjhart...@gmail.com writes: Is it possible to map Table instances back to classes defined through declarative_base()? the typical form is: Base = declarative_base() some_table = Table

[sqlalchemy] views declarative?

2013-04-17 Thread James Hartley
Starting with the Wiki article on implementing views: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/Views Is it possible to map Table instances back to classes defined through declarative_base()? I'm using SQLAlchemy 0.7.1. Thanks. -- You received this message because you are subscribed

Re: [sqlalchemy] Re: views declarative?

2013-04-17 Thread James Hartley
On Wed, Apr 17, 2013 at 6:20 AM, Lele Gaifax l...@metapensiero.it wrote: James Hartley jjhart...@gmail.com writes: Is it possible to map Table instances back to classes defined through declarative_base()? ...I assume you are asking whether you can map a view onto a Python class using

Re: [sqlalchemy] implementing one-to-many relationship?

2013-04-14 Thread James Hartley
-to-many, I don't see the use of relationship() here, you'd likely find it easier to use rather than assigning primary key identities to foreign key attributes directly: http://docs.sqlalchemy.org/en/rel_0_8/orm/tutorial.html#building-a-relationship On Apr 3, 2013, at 2:49 PM, James Hartley jjhart

[sqlalchemy] implementing one-to-many relationship?

2013-04-03 Thread James Hartley
I have implemented a (simplified) one-to-many relationship which works, but I suspect I am reimplementing functionality in a suboptimal fashion which is already done by SQLAlchemy. The following short example: 8--- #!/usr/bin/env python import datetime from sqlalchemy

[sqlalchemy] max() min() string lengths?

2013-01-03 Thread James Hartley
Embarrassingly, I'm gotten lost in calling SQL functions in SQLAlchemy 0.7.1. I can boil the problem down to the following table structure: CREATE TABLE words ( id INTEGER NOT NULL, timestamp DATETIME NOT NULL, word TEXT NOT NULL, PRIMARY KEY (id), UNIQUE

Re: [sqlalchemy] defining foreign keys?

2011-10-26 Thread James Hartley
On Wed, Oct 26, 2011 at 10:15 AM, Michael Bayer mike...@zzzcomputing.comwrote: On Oct 26, 2011, at 1:04 PM, James Hartley wrote: On Wed, Oct 26, 2011 at 2:22 AM, Stefano Fontanelli s.fontane...@asidev.com wrote: Hi James, you cannot define two mapper properties that use the same name

[sqlalchemy] defining foreign keys?

2011-10-25 Thread James Hartley
I suspect this is user error, but I am not ferreting out my mistake. I'm porting some older code to SQLAlchemy 0.71 on top of Python 2.7.1. Code which had originally implemented foreign keys without using REFERENCES clauses in CREATE TABLE statements previously ran fine. Now, adding formal

[sqlalchemy] support of regular expressions?

2011-09-11 Thread James Hartley
I'm needing to extract domain information from stored email addresses -- something akin to the following: SELECT DISTINCT (REGEXP_MATCHES(email, '@(.+)$'))[1] AS domain FROM tablename WHERE email ~ '@.+$' While I was able to gather the information through session.execute(), I didn't find an

[sqlalchemy] NamedTuple error in multiple join?

2010-10-30 Thread James Hartley
I'm using SQLAlchemy 0.6.4 on top of OpenBSD utilitizing PostgreSQL 8.4.4. As a first project, I am gathering statistics on the availability of another Open Source project. The schema is normalized, the following SQL query (which works at the console) to find the latest snapshot is giving me