[sqlalchemy] Setting up indexes in __table_args__ that depend on columns created in __declare_first__

2021-12-14 Thread 'Randy Syring' via sqlalchemy
I'm trying to create a mixin that will setup FK columns that are dynamically named based on the name of the parent as opposed to a static name like `parent_id`. If was going to do the latter, I could easily use `declarted_attr` but since I want the former, I thought I could use

[sqlalchemy] Can I get joined loading on a relationship to work from child to parent?

2017-05-02 Thread Randy Syring
Is there any way to get relationship joined loading to work from child back up to the parent? from sqlalchemy import create_engine, Column, Integer, String, ForeignKey from sqlalchemy.orm import relationship, sessionmaker from sqlalchemy.ext.declarative import declarative_base engine =

Re: [sqlalchemy] Proposal to discontinue pymssql in favor of pyodbc

2017-01-25 Thread Randy Syring
g anything to the table that pyodbc doesn't bring, then why shouldn't we point people in that direction instead. However, I appreciate your input here and on the GH issue that pymssql is more stable than pyodbc. That is exactly the kind of information I'm looking for. *Randy Syring* Chief

[sqlalchemy] Proposal to discontinue pymssql in favor of pyodbc

2017-01-25 Thread Randy Syring
There is a proposal open to discontinue pymssql development and point people towards pyodbc. Since pymssql is a documented backend for SA, I figured there might be some people here who are interested. If you have any skin in that game and want to comment, please visit the issue:

Re: [sqlalchemy] Memory leak? with connection & insert

2016-02-25 Thread Randy Syring
Mike, Just to be clear, I'm not doing any kind of selects. I'm only inserting records. And these aren't large binary blobs of any kind, they are rather small strings and ints. I apologize in advance if I misunderstood your answer. *Randy Syring* Chief Executive Developer Direct

[sqlalchemy] Memory leak? with connection & insert

2016-02-25 Thread Randy Syring
I'm working on a project to parse through a large text file (1GB) of records. Once parsed, each record gets sent to the DB. Due to the size of the file, I've been working on a streaming/functional approach that will keep my memory usage constant. I've been able to simply take the DB out of

Re: [sqlalchemy] UTC timestamps for Column's server_default?

2015-07-24 Thread Randy Syring
So helpful! Thanks. *Randy Syring* Chief Executive Developer Direct: 502.276.0459 Office: 812.285.8766 Level 12 https://www.level12.io/ On 07/24/2015 03:45 PM, Mike Bayer wrote: On 7/24/15 3:17 PM, Randy Syring wrote: I have some generic timestamp columns as part of a mixin. I'd like

[sqlalchemy] UTC timestamps for Column's server_default?

2015-07-24 Thread Randy Syring
I have some generic timestamp columns as part of a mixin. I'd like for these columns to have server defaults of the current UTC time. If I wanted local time, I could just do: created_ts = Column(DateTime, ..., server_default=sasql.text('CURRENT_TIMESTAMP')) The problem I'm running into is

[sqlalchemy] Do passive deletes apply to many to many relationships?

2014-05-14 Thread Randy Syring
I am trying to get SQLAlchemy to let my database's foreign keys on delete cascade do the cleanup on the association table between two objects. I have setup the cascade and passive_delete options on the relationship as seems appropriate from the docs. However, when a related object is loaded

Re: [sqlalchemy] Turning a Query instance into SQL (with parameters), need help w/ LIMIT/OFFSET in 0.7.x

2012-03-12 Thread Randy Syring
I added the new recipe to the wiki. - Randy Syring Development Executive Director Level 12 Technologies https://www.lev12.com/ (formerly Intelicom) Direct: 502-276-0459 Office: 502-212-9913 Intelicom is now Level 12 Technologies,learn more about

Re: [sqlalchemy] Turning a Query instance into SQL (with parameters), need help w/ LIMIT/OFFSET in 0.7.x

2012-03-09 Thread Randy Syring
Excellent, thank you! - Randy Syring Development Executive Director Level 12 Technologies https://www.lev12.com/ (formerly Intelicom) Direct: 502-276-0459 Office: 502-212-9913 Intelicom is now Level 12 Technologies,learn more about our name change

Re: [sqlalchemy] Turning a Query instance into SQL (with parameters), need help w/ LIMIT/OFFSET in 0.7.x

2012-03-09 Thread Randy Syring
? However, I was mistaken in my original post. The problem was not with the helper function but with the way I was doing my testing. The full implementation of the helper function is here: http://stackoverflow.com/a/5698357/182111 - Randy Syring

[sqlalchemy] Turning a Query instance into SQL (with parameters), need help w/ LIMIT/OFFSET in 0.7.x

2012-03-08 Thread Randy Syring
I found a recipe on stackoverflow for turning a query instance into a string, including parameters. I only do this for testing purposes and the implementation is here: https://bitbucket.org/rsyring/sqlalchemybwc/src/292597b37736/sqlalchemybwc/lib/testing.py However, I just upgraded to 0.7.5

[sqlalchemy] Re: Help using SqlSoup with database views

2011-08-04 Thread Randy Syring
FWIW, I tried the map_to() method but still received the PK error. The following method, however, worked fine: ss = SqlSoup(db.engine) meta = ss._metadata tbl_vrmf = sa.Table(vRMF, meta, autoload=True) vrmf_pks = [tbl_vrmf.c.dateId, tbl_vrmf.c.ident, tbl_vrmf.c.mnum] vrmf = ss.map(tbl_vrmf,

Re: [sqlalchemy] Re: can I use SA to dump a table's DDL to a file?

2011-06-03 Thread Randy Syring
If anyone is interested, I have some code that writes basic details for tables, constraints, indexes, and triggers out to files. Code is here: https://bitbucket.org/rsyring/mssqlddlwriter/ -- Randy Syring Intelicom Direct: 502-276-0459 Office: 502-212-9913

[sqlalchemy] Re: can I use SA to dump a table's DDL to a file?

2011-06-02 Thread Randy Syring
executor as in the second example here:http://www.sqlalchemy.org/trac/wiki/FAQ#HowcanIgettheCREATETABLEDROPT... On Jun 1, 2011, at 8:01 PM, Randy Syring wrote: I'd like to be able to dump an MS SQL server's objects to text on the local file system.  I have a working solution for views

Re: [sqlalchemy] Re: can I use SA to dump a table's DDL to a file?

2011-06-02 Thread Randy Syring
That was it, thanks. I was trying to go through the column and looking at it's foreign_keys collection. When I set those values, it didn't affect the output. Reflects my ignorance of SA, obviously. Thanks again. -- Randy Syring Intelicom Direct: 502-276

[sqlalchemy] can I use SA to dump a table's DDL to a file?

2011-06-01 Thread Randy Syring
I'd like to be able to dump an MS SQL server's objects to text on the local file system. I have a working solution for views, stored procedures, and functions, but tables are a different story. Can i use SA's reflection and table creation abilities to write create table DDL to a text file? --

[sqlalchemy] Re: can I use SA to dump a table's DDL to a file?

2011-06-01 Thread Randy Syring
In the FAQ...sorry: http://www.sqlalchemy.org/trac/wiki/FAQ#HowcanIgettheCREATETABLEDROPTABLEoutputasastring On Jun 1, 8:01 pm, Randy Syring ra...@rcs-comp.com wrote: I'd like to be able to dump an MS SQL server's objects to text on the local file system.  I have a working solution for views

[sqlalchemy] Re: pyodbc + FreeTDS segfault?? on linux

2011-04-07 Thread Randy Syring
Seems to be a unicode conversion problem, if you are interested in following, the pyodbc issue with very small test case is here: http://code.google.com/p/pyodbc/issues/detail?id=170 On Apr 7, 9:37 am, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 7, 2011, at 12:46 AM, Randy Syring wrote

[sqlalchemy] pyodbc + FreeTDS segfault?? on linux

2011-04-06 Thread Randy Syring
I am running Ubuntu 10.04, python 2.6.5, SA 0.6.6, latest pyodbc release. I have tried FreeTDS that ships with the distro (0.82) as well as current CVS. I can make a connection and issue a basic SQL statement. However, when I try to run my unit tests, I get the following error: *** glibc

[sqlalchemy] MSSQL: OUTPUT clause is throwing an error on a table with an INSERT trigger

2010-12-06 Thread Randy Syring
I am executing a bulk insert which is resulting in SQL like: INSERT INTO equipment (equipment_type_id, number, mark, inactive) OUTPUT inserted.id VALUES (?, ?, ?, ?)' (6, u'1', None, 0) But I have a trigger on equipment that does some validity checking. When executing, I get an exception

[sqlalchemy] Re: MSSQL: OUTPUT clause is throwing an error on a table with an INSERT trigger

2010-12-06 Thread Randy Syring
PM, Randy Syring wrote: I am executing a bulk insert which is resulting in SQL like: INSERT INTO equipment (equipment_type_id, number, mark, inactive) OUTPUT inserted.id VALUES (?, ?, ?, ?)' (6, u'1', None, 0) But I have a trigger on equipment that does some validity checking. When

[sqlalchemy] SAValidation: class-level validation for Declarative objects

2010-11-24 Thread Randy Syring
I wanted to let others know about a project I am working on to give active record style validations to declarative SA classes. The idea is that you can declare validation on individual fields or the whole class and have those validators fire when the session is flushed. I am not an SA guru by

[sqlalchemy] documentation correction on declarative mixin

2010-07-09 Thread Randy Syring
http://www.sqlalchemy.org/docs/reference/ext/declarative.html#controlling-table-inheritance-with-mixins In the second example, Engineer has __tablename__ = None But, I think the point of that section, is that it wouldn't be needed. __tablename__ in Tablename should assign None anyway, shouldn't

[sqlalchemy] negative implications of using multiple declarative Base classes

2010-07-08 Thread Randy Syring
I have been, naively it seems, using multiple declarative Base classes in my webapp. They all share the same metadata object. I have found one negative ramification of this, which is that string references (like what can be used in relation()) won't find the object if they are not using the same

[sqlalchemy] model validation library, need help with extension sequencing

2010-04-19 Thread Randy Syring
I am developing a library to do Active Record style validations on SA declarative instances: http://bitbucket.org/rsyring/sqlalchemy-validation/src/tip/savalidation/ I know there are differences of opinion on the value of doing validation like this, but I am really hoping to avoid that

Re: [sqlalchemy] Re: model validation library, need help with extension sequencing

2010-04-19 Thread Randy Syring
. -- Randy Syring Intelicom 502-644-4776 Whether, then, you eat or drink or whatever you do, do all to the glory of God. 1 Cor 10:31 Randy Syring wrote: Mike, Thank you for your quick reply. If I understand correctly, after_flush() will get called after the SQL

[sqlalchemy] Any libraries or examples of how to let users define custom fields on SA tables/objects

2010-04-18 Thread Randy Syring
I am creating a web application that has the concept of organizations and people. I would like the end users to be able to define custom fields on those objects as needed. So, User A (only default fields): Organization: - Name - Zip People: - Name - Phone Number User B (has a few custom

[sqlalchemy] Re: How to get SA column object from table.col, declarative attribute, or elixir entity attribute

2009-10-07 Thread Randy Syring
Can anyone give me an idea of what I need to do here? If I can just get a high level overview of what I need to do, I am happy to read the documentation and source to fill in the details. Thanks. On Oct 1, 1:56 pm, Randy Syring ra...@rcs-comp.com wrote: Mike, Thank you for the prompt reply

[sqlalchemy] How to get SA column object from table.col, declarative attribute, or elixir entity attribute

2009-10-01 Thread Randy Syring
I am trying to write a datagrid library for sqlalchemy which will allow easy generation of tables from SA objects. I would like the datagrid to be able to accept a table column, declarative attribute, or elixir entity attribute interchangeably. Since I am building the SQL with queries, this has

[sqlalchemy] Re: Proper way to use case() in a filter()?

2009-08-12 Thread Randy Syring
Mike, Thank you for the reply. That looks very close to what I have. At the very least, my understanding about what I should be able to do looks correct. I will do some further testing and examination and post back with details. Thanks again. -- Randy

[sqlalchemy] Proper way to use case() in a filter()?

2009-08-11 Thread Randy Syring
I have a case(...) that looks right when I print it and am now trying to use it in a filter, something like: sess.query(User).select_from(join(...)).filter(case(...) == 1) But I get an error. When dissecting the parts, the problem is coming from the case(...) == 1 part. Can someone tell me

[sqlalchemy] Re: autoload of db view treating columns as Decimal

2009-07-23 Thread Randy Syring
On Jul 22, 9:02 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jul 22, 2009, at 8:48 PM, Randy Syring wrote: well this is really easy to analyze, turn on echo=debug and see what SQLite is returning. The mapping of SQLite names to SQLA column types in the 0.5 series is in sqlalchemy

[sqlalchemy] Re: autoload of db view treating columns as Decimal

2009-07-22 Thread Randy Syring
I work with the OP. The columns are correctly typed and the reflection code seems to work correctly with views that are directly selecting from tables. Its when a view selects from another view that we have problems with the type being lost. Can anyone else say for sure whether it is supported

[sqlalchemy] Missing Post: mssql and pyodbc weirdness

2009-06-01 Thread Randy Syring
I made a post on Friday about some issues I was having with pyodbc and mssql. Now I can't find it. I feel like I am losing my mind. Does anyone remember seeing that post? I have tried just about every search combination I can think of and can't find the post anywhere. Thanks.

[sqlalchemy] Re: Missing Post: mssql and pyodbc weirdness

2009-06-01 Thread Randy Syring
 pm, Randy Syring ra...@rcs-comp.com wrote: I made a post on Friday about some issues I was having with pyodbc and mssql.  Now I can't find it.  I feel like I am losing my mind.  Does anyone remember seeing that post?  I have tried just about every search combination I can think of and can't find

[sqlalchemy] Re: mssql and pyodbc weirdness with data not saving

2009-06-01 Thread Randy Syring
Darn! I thought I checked that. But you are right. Thank you for the post! On Jun 1, 3:55 pm, mtrier mtr...@gmail.com wrote: Looks like you're using 0.5.3 I believe which had problems with this. Upgrade to a later release. Thanks, Michael

[sqlalchemy] mssql and pyodbc weirdness with data not saving

2009-05-29 Thread Randy Syring
I have been having a weird thing happen when using pyodbc with mssql. The create table statements work, but none of the INSERT statements do. For example, when I run code and echo, I get this: (TCSData) F:\Inetpub\TCSData\src\tcsdata-dist\tcsdatapysmvt broadcast initapp calling:

[sqlalchemy] Re: Query.delete() doesn't cascade on Sqlite

2009-05-29 Thread Randy Syring
Another solution is to use triggers in SQLite to enforce FK relationships. http://www.sqlite.org/cvstrac/wiki?p=ForeignKeyTriggers http://code.google.com/p/sqlitefktg4sa/ On May 29, 6:59 am, Mike Conley mconl...@gmail.com wrote: One solution is to change the commit strategy; issue commits

[sqlalchemy] Re: Query.delete() doesn't cascade on Sqlite

2009-05-29 Thread Randy Syring
be true with triggers? After all, if the problem is that the transaction is too big, it will still be too big with all the pending deletes executed in a trigger. -- Mike Conley On Fri, May 29, 2009 at 8:47 AM, Randy Syring ra...@rcs-comp.com wrote: Another solution is to use triggers in SQLite

[sqlalchemy] Re: Query.delete() doesn't cascade on Sqlite

2009-05-29 Thread Randy Syring
it was an embedded system, probably all resources are pretty severely restricted. -- Mike Conley On Fri, May 29, 2009 at 9:44 AM, Randy Syring ra...@rcs-comp.com wrote: Mike, Well...I am not sure.  I thought SQLite held transaction details in a .journal file and not in memory.  I thought

[sqlalchemy] MSSQL Stored Procedures with output (OUT) parameters

2009-05-20 Thread Randy Syring
I have searched the list and have seen some examples with Oracle and I have seen some examples with MSSQL using 'exec' but without parameters. So, I was hoping that someone could give me or point me to an example of using a MSSQL stored procedure with both input and output parameters as well as

[sqlalchemy] Stale ORM Objects Locking Best Practice (for nested sets)

2009-04-01 Thread Randy Syring
I have a nested set implementation that I am working on. Currently, the steps involved to make a change to the table are: 1) Retrieve parent node (ORM Object) 2) Create new node (same ORM object as #1) 3) Calculate UPDATE boundaries, etc. from anchor node 4) Create UPDATE SQL based on #3 5)

[sqlalchemy] Re: Stale ORM Objects Locking Best Practice (for nested sets)

2009-04-01 Thread Randy Syring
Michael, Thanks for your reply. On Apr 1, 11:46 am, Michael Bayer mike...@zzzcomputing.com wrote: there's a nested set demo in the examples/ folder of the distribution, which uses MapperExtension as well as a little-used flag on the mapper called batch=False.   are you building off of that ?

[sqlalchemy] Re: SQLite connections shared across threads (test case and logs)

2008-11-16 Thread Randy Syring
On Nov 16, 11:30 am, Michael Bayer [EMAIL PROTECTED] wrote: I've looked into PyISAPIe.    Suffice to say this seems to be an   extremely new project.  Their homepage is blank: It has been around for a couple years: http://web.archive.org/web/*/http://pyisapie.sourceforge.net/ But I agree

[sqlalchemy] Re: Should create_engine() be called per-process or per-request in threaded wsgi environment?

2008-11-16 Thread Randy Syring
Problem turns out to have been with my ISAPI WSGI interface, it looks like it has a broken thread local model. More details here if anyone is interested: http://groups.google.com/group/sqlalchemy/browse_thread/thread/fbca1399020f6a2e On Nov 6, 5:19 pm, Randy Syring [EMAIL PROTECTED] wrote

[sqlalchemy] SQLite connections shared across threads (test case and logs)

2008-11-15 Thread Randy Syring
As noted here, I have been having some problems with SQLite connections: http://groups.google.com/group/sqlalchemy/browse_thread/thread/5f742fdd313f3da9/ I went ahead and produced what I hope is a very narrow test case to show that I am not explicitly holding onto connections (unless I

[sqlalchemy] Re: SQLite connections shared across threads (test case and logs)

2008-11-15 Thread Randy Syring
On Nov 15, 6:39 pm, Michael Bayer [EMAIL PROTECTED] wrote: Thank you so much for your response, I am extremely grateful. However, I am still getting exceptions thrown from SQLite for sharing connections across threads. The explicit connection as well as the threadlocal strategy are all

[sqlalchemy] Should create_engine() be called per-process or per-request in threaded wsgi environment?

2008-11-06 Thread Randy Syring
I am developing a WSGI based web framework with sqlalchemy. I am unclear about when create_engine() should be called. I initially thought that engine creation and metadata would be initialized per process and each thread/request would just get a new session. However, I have recently run into

[sqlalchemy] Re: Should create_engine() be called per-process or per-request in threaded wsgi environment?

2008-11-06 Thread Randy Syring
Thank you for taking the time to respond, I really appreciate it! On Nov 6, 2:46 pm, Michael Bayer [EMAIL PROTECTED] wrote: you should definitely create the engine and metadata on a per-process   basis.   When using SQLite, the engine automatically chooses the   SingletonThreadPool

[sqlalchemy] adding children to ORM object using property causes problems, maybe a bug?

2008-10-02 Thread Randy Syring
After some work with Gedd on #sqlalchemy, it seems that adding children to a parent object using a custom property() doesn't work as we expected it would. A test case is here: http://paste.pocoo.org/show/86848/ The error is triggered by line #53. Are we doing something wrong or is this a bug

[sqlalchemy] How to turn off UPDATE on child objects when deleting parent object

2008-09-30 Thread Randy Syring
More details are here: http://groups.google.com/group/sqlelixir/browse_thread/thread/aac5d22702e3a8ec But basically, I have a relationship between a parent (Item) table and child (Link) table. When I try to delete an Item, an SQL statement is generated by SQLAlchemy that tries to set

[sqlalchemy] Re: How to turn off UPDATE on child objects when deleting parent object

2008-09-30 Thread Randy Syring
, Randy Syring [EMAIL PROTECTED] wrote: More details are here:http://groups.google.com/group/sqlelixir/browse_thread/thread/aac5d22... But basically, I have a relationship between a parent (Item) table and child (Link) table.  When I try to delete an Item, an SQL statement is generated

[sqlalchemy] Re: How to turn off UPDATE on child objects when deleting parent object

2008-09-30 Thread Randy Syring
Simon, THANK YOU!! Yes, I believe that will do it. On Sep 30, 5:12 am, King Simon-NFHD78 [EMAIL PROTECTED] wrote: -Original Message- From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Randy Syring Sent: 30 September 2008 07:17 To: sqlalchemy Subject

[sqlalchemy] Looking for HTML table generator based on SQLAlchemy query

2008-09-05 Thread Randy Syring
Has anyone written or seen something that would take an SQLAlchemy query, any query, and turn the resulting recordset into an HTML table? Bonus points for providing a sort, filter, and paging feature. Thanks. --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: SQLite Foreign Key Triggers: how to extend sqlalchemy to generate them

2008-08-27 Thread Randy Syring
like- the event name will be passed in as the first argument. Randy Syring wrote: Jason, Thank you for the response.  Using the method you suggest, am I understanding correctly that fks_for_sqlite() would only be run when a create() was processed for that table?  Also, I am assuming I

[sqlalchemy] Re: SQLite Foreign Key Triggers: how to extend sqlalchemy to generate them

2008-08-27 Thread Randy Syring
Gaëtan, Thank you. On Aug 27, 5:23 am, Gaetan de Menten [EMAIL PROTECTED] wrote: On Wed, Aug 27, 2008 at 3:21 AM, Randy Syring [EMAIL PROTECTED] wrote: Ok, so I was going to try and implement a solution using the method discussed here, but ran into a problem b/c I am using Elixir objects

[sqlalchemy] Re: SQLite Foreign Key Triggers: how to extend sqlalchemy to generate them

2008-08-26 Thread Randy Syring
, jason kirtland [EMAIL PROTECTED] wrote: Yep, though possibly you'd want it on before-drop.  You can actually handle both tasks in the same function if you like- the event name will be passed in as the first argument. Randy Syring wrote: Jason, Thank you for the response.  Using the method

[sqlalchemy] SQLite Foreign Key Triggers: how to extend sqlalchemy to generate them

2008-08-22 Thread Randy Syring
I would like sqlalchemy to generate triggers on an SQLite database to enforce foreign key relationships. The method is documented here: http://www.sqlite.org/cvstrac/wiki?p=ForeignKeyTriggers and I have written a foreign key trigger generator here:

[sqlalchemy] Re: SQLite Foreign Key Triggers: how to extend sqlalchemy to generate them

2008-08-22 Thread Randy Syring
can be pulled out using: for c in table.c:         for fk in c.foreign_keys:                 do_something_with_fk(fk) On Aug 22, 2008, at 11:19 AM, Randy Syring wrote: I would like sqlalchemy to generate triggers on an SQLite database to enforce foreign key relationships.  The method

[sqlalchemy] Re: SQLite Foreign Key Triggers: how to extend sqlalchemy to generate them

2008-08-22 Thread Randy Syring
using: for c in table.c:    for fk in c.foreign_keys:            do_something_with_fk(fk) On Aug 22, 2008, at 11:19 AM, Randy Syring wrote: I would like sqlalchemy to generate triggers on an SQLite database to enforce foreign key relationships.  The method is documented here: http