[sqlalchemy] hybrid_properties and literals

2014-06-19 Thread AM
Hi. I am having some trouble understanding how to use native python data types with hybrid properties. I have the following model. I am using flask-sqlalchemy however I run into the same issue in straight sqlalchemy too. class SystemModel(BaseModel): __tablename__ = 'system'

Re: [sqlalchemy] Functions on column properties

2014-06-19 Thread Mike Solomon
not looking deeply but the hybrid you have in prop_3 doesn't seem to have any relationship to the base set of rows you're getting from fractions. it returns multiple rows because statement2 isn't using any aggregates. How about a straight SQL string? what SQL do you expect? these are

Re: [sqlalchemy] Functions on column properties

2014-06-19 Thread Mike Bayer
On 6/19/14, 4:09 AM, Mike Solomon wrote: It's difficult to issue a straight SQL string for the hybrid property itself because sorry, I meant, please write the query *that you really want* as a SQL string. Don't use SQLAlchemy. It's better to work in that direction. If you don't know

Re: [sqlalchemy] hybrid_properties and literals

2014-06-19 Thread AM
On 06/19/2014 06:13 AM, Mike Bayer wrote: On 6/19/14, 2:05 AM, AM wrote: Hi. I am having some trouble understanding how to use native python data types with hybrid properties. I have the following model. I am using flask-sqlalchemy however I run into the same issue in straight sqlalchemy too.

Re: [sqlalchemy] hybrid_properties and literals

2014-06-19 Thread Mike Bayer
On 6/19/14, 1:05 PM, AM wrote: What I am storing is things like string versions of lists, tuples and dicts, for e.g.: str([1, 2, 3]) str({'a':1} and so on. ast.literal_eval will only parse those and return those, it does not evaluate expressions and statements so no real code at all. I

[sqlalchemy] unable to open database file

2014-06-19 Thread Scott Horowitz
Hi, A user of my applicable is getting a unable to open database file None None error because the file path to their database has a Á character in it. It works fine if the character is removed, but that is not a good solution. Does anyone know how to solve this? Thanks, Scott -- You

Re: [sqlalchemy] Functions on column properties

2014-06-19 Thread Mike Solomon
Le jeudi 19 juin 2014 16:10:19 UTC+3, Michael Bayer a écrit : On 6/19/14, 4:09 AM, Mike Solomon wrote: It's difficult to issue a straight SQL string for the hybrid property itself because sorry, I meant, please write the query *that you really want* as a SQL string.

Re: [sqlalchemy] unable to open database file

2014-06-19 Thread Mike Bayer
no but this is more of a pysqlite/sqlite3 issue, you should ask on the Python users list, and refer to the sqlite3.connect() function: import sqlite3 conn = sqlite3.connect(/path/to/file.db) On 6/19/14, 2:28 PM, Scott Horowitz wrote: Hi, A user of my applicable is getting a unable to open

Re: [sqlalchemy] Functions on column properties

2014-06-19 Thread Mike Bayer
On 6/19/14, 2:41 PM, Mike Solomon wrote: Le jeudi 19 juin 2014 16:10:19 UTC+3, Michael Bayer a écrit : On 6/19/14, 4:09 AM, Mike Solomon wrote: It's difficult to issue a straight SQL string for the hybrid property itself because sorry, I meant,

Re: [sqlalchemy] unable to open database file

2014-06-19 Thread Scott Horowitz
Michael, Thanks for the hint about python's sqlite3. I'll just point out that I can work around the issue directly with sqlite3 by providing a relative path that does not include the character: import sqlite3, os os.chdir(/path/with/non/ascii/character) conn = sqlite3.connect(file.db)

Re: [sqlalchemy] unable to open database file

2014-06-19 Thread Mike Bayer
On 6/19/14, 3:37 PM, Scott Horowitz wrote: Michael, Thanks for the hint about python's sqlite3. I'll just point out that I can work around the issue directly with sqlite3 by providing a relative path that does not include the character: import sqlite3, os

Re: [sqlalchemy] Functions on column properties

2014-06-19 Thread Mike Solomon
Le jeudi 19 juin 2014 22:07:14 UTC+3, Michael Bayer a écrit : So to the extent that 1.0 * num / den is a column-based expression you like to use in your query, it's a good candidate for a hybrid or column_property (deferred one in case you don't want to load it unconditionally). But as

Re: [sqlalchemy] unable to open database file

2014-06-19 Thread Scott Horowitz
Ah great, that is much better than having to modify sqlalchemy code. Indeed, the below code works for me: os.chdir(os.path.dirname(db_path)) e = create_engine(sqlite:///, creator=lambda: sqlite3.connect(os.path.basename(db_path))) Thanks! Scott On Thu, Jun 19, 2014 at 2:09 PM, Mike Bayer

[sqlalchemy] correlating related deletes

2014-06-19 Thread Jonathan Vanasco
Due to a business requirement and an odd distribution of data / performance issue, my database currently has 2 tables which are inter-related : class Relationship(): id_a = int ,references table_a(id) id_b = int, references table_b(id) relationship_id = int,

Re: [sqlalchemy] correlating related deletes

2014-06-19 Thread Mike Bayer
On 6/19/14, 8:02 PM, Jonathan Vanasco wrote: Due to a business requirement and an odd distribution of data / performance issue, my database currently has 2 tables which are inter-related : class Relationship(): id_a = int ,references table_a(id) id_b = int, references

Re: [sqlalchemy] hybrid_properties and literals

2014-06-19 Thread AM
On 06/19/2014 10:24 AM, Mike Bayer wrote: On 6/19/14, 1:05 PM, AM wrote: What I am storing is things like string versions of lists, tuples and dicts, for e.g.: str([1, 2, 3]) str({'a':1} and so on. ast.literal_eval will only parse those and return those, it does not evaluate expressions and