[sqlalchemy] some gotchas in SQLAlchemy 2.0 and how to fix

2023-02-23 Thread Victor Olex
Hi guys, I came across a bunch of issues in a relatively simple code I got when upgraded to SQLA 2.0. Below I provided issues seen and solutions, but very much welcome any corrections. I thought this might come in handy for some. As a side note not since the move from like 0.4 to 0.5 or 0.6

Re: [sqlalchemy] boud parameter to NCHAR column in Oracle

2019-10-12 Thread Victor Olex
That's for CHAR not NCHAR. I will open a bug report. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full

Re: [sqlalchemy] boud parameter to NCHAR column in Oracle

2019-10-11 Thread Victor Olex
A bit of advocacy from my side on cx_Oracle: https://github.com/oracle/python-cx_Oracle/issues/365 Mike, there's something you might want to look at. We have this monkey patch on SQLAlchemy in our recent code, which was necessary to get the correct behavior for NCHAR columns. from

[sqlalchemy] Re: boud parameter to NCHAR column in Oracle

2019-10-03 Thread Victor Olex
I'd add that other dialects such as pyodbc+mssql work as expected, which is to ignore trailing white space in fixed width character fields for comparison purposes. On Thursday, October 3, 2019 at 4:47:41 AM UTC-4, mdob wrote: > > Hi everyone, > > There's IMO unusual behavior in Oracle when

[sqlalchemy] limit in context of entities not rows

2019-07-04 Thread Victor Olex
Using ORM querying what is the best practice for limiting the output to a given number of resulting *entities*? Consider this model: from sqlalchemy import Column, DateTime, String, Integer, ForeignKey, func from sqlalchemy.orm import relationship, backref from sqlalchemy.ext.declarative import

Re: [sqlalchemy] binding parameters in quotes

2019-03-22 Thread Victor Olex
ELECT * from T WHERE C1 = :param1 and C2 = 'Group :A'") >>> print(q.compile()) SELECT * from T WHERE C1 = :param1 and C2 = 'Group :A' >>> print(q.compile().params) {'param1': None, 'A': None} On Thursday, March 21, 2019 at 4:11:45 PM UTC-4, Mike Bayer wrote: > > On

Re: [sqlalchemy] binding parameters in quotes

2019-03-21 Thread Victor Olex
Thanks Mike, though the question is valid - why does regex in SQLAlchemy allow for discovering parameter token inside quotes? Have you seen a legitimate case for that? On Wednesday, March 20, 2019 at 9:58:58 AM UTC-4, Mike Bayer wrote: > > On Wed, Mar 20, 2019 at 7:59 AM mdob > > wrote: > >

Re: [sqlalchemy] reflecting stored procedure names, enums, and the like

2018-03-09 Thread Victor Olex
Reflecting stored procedure as first class model objects could be very useful. I would imagine those objects be Python callable bound to an engine or session. On Tuesday, August 16, 2016 at 10:28:25 AM UTC-4, Mike Bayer wrote: > > > > On 08/16/2016 03:33 AM, Chris Withers wrote: > > Gotcha,

Re: [sqlalchemy] inheriting from mapped classes

2014-06-26 Thread Victor Olex
I read it, but could you illustrate it with a sample code based on the classic User/Addresses example? On Wednesday, June 25, 2014 11:45:12 AM UTC-4, Jonathan Vanasco wrote: On Tuesday, June 24, 2014 9:40:02 PM UTC-4, Victor Olex wrote: What I aiming for is to provide users a library

Re: [sqlalchemy] inheriting from mapped classes

2014-06-24 Thread Victor Olex
may get a User back, not a Thinker (or you will, if it hasn’t been expired. you can’t rely on it being consistent). If that’s OK, then set the flag - it just wants to check that this is what you intend. On May 30, 2014, at 1:51 PM, Victor Olex victo...@vtenterprise.com javascript

Re: [sqlalchemy] inheriting from mapped classes

2014-06-24 Thread Victor Olex
, June 24, 2014 6:39:03 PM UTC-4, Michael Bayer wrote: On 6/24/14, 5:44 PM, Victor Olex wrote: So, what is the right idiom for building SQLAlchemy persistence into classes that need to do more than just that i.e. have run-time state. I was hoping that deriving from SQLAlchemy model classes

[sqlalchemy] inheriting from mapped classes

2014-05-30 Thread Victor Olex
Hello all, long time no see... Is it OK to create classes, which inherit from mapped classes, but are not meant to be persited and how to do it as to avoid FlushError on related classes? from sqlalchemy import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import

Re: [sqlalchemy] oracle reflect with duplicated tables (schema casing)

2013-07-24 Thread Victor Olex
Hey Mike, thanks for chiming in. Popular tool Oracle SQL Develoepr generally produces DDL with quoted identifiers so in real life you will encounter a lot of situations where some tables were created using quoted and some unquoted as people work on maintaining the database. Using lowercase

[sqlalchemy] Re: DBAPIError

2013-01-18 Thread Victor Olex
Have you every found the root cause for this? I am experiencing the same issue in one of our setups. On Monday, February 15, 2010 11:47:46 AM UTC-5, fdelia wrote: hello, I developed an application that uses SQLAlchemy to write the records on the server. I have freetds 0.82.6 on the server.

[sqlalchemy] mapping without key

2012-06-06 Thread Victor Olex
With the understanding that we would loose the ability to properly track the sate of a mapped object and ability to update or insert in ORM and likely the ability to correctly use relationships as well - how can one accomplish a mapper, which would work on tables (views) without any key, which

[sqlalchemy] Re: mapping without key

2012-06-06 Thread Victor Olex
rows to come back as individual objects, Query() can be handed Table objects to load rows from, so a custom Query subclass that wraps named tuples into objects could possibly approximate this effect. On Jun 6, 2012, at 3:01 PM, Victor Olex wrote: With the understanding that we would

[sqlalchemy] Re: mapping without key

2012-06-06 Thread Victor Olex
To be clear this is not a feature request. I could use a hit how to build a fake mapper like this if not compatible in certain cases. On Jun 6, 5:52 pm, Victor Olex victor.o...@vtenterprise.com wrote: Thanks. Model that we work with has tables, which have no unique constraints. Keys can

[sqlalchemy] Re: override char() handling

2012-02-08 Thread Victor Olex
Yeah, this will keep coming back as long as people work with schemas, which use fixed length character types (CHAR, NCHAR), which is probably for another 30 years. May I propose an enhancement to String (and as a result to CHAR, NCHAR and Unicode) to take trim=False keyword and effect a TRIM()

[sqlalchemy] using Events to reduce memory footprint?

2011-11-07 Thread Victor Olex
I am curious if Events (new feature as of 0.7) could be used to reduce memory footprint in certain situations or is it better achieved with other features such as lazy loading. For example, consider a complex mapped object (containing at least one related table). Using joinedload_all option,

[sqlalchemy] Re: using Events to reduce memory footprint?

2011-11-07 Thread Victor Olex
something good. On Nov 7, 1:36 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Nov 7, 2011, at 7:14 AM, Victor Olex wrote: I am curious if Events (new feature as of 0.7) could be used to reduce memory footprint in certain situations or is it better achieved with other features

[sqlalchemy] Re: UnicodeEncodeError on saving to MySQL

2011-09-29 Thread Victor Olex
I am of the opinion that unless you are absolutely certain that the data will be pure ASCII you should declare string fields in model as Unicode type rather than String. Also have a look at http://farmdev.com/talks/unicode/ because it will help you understand what the dreaded error really means.

[sqlalchemy] SQLAchemy architecture in slides

2011-09-22 Thread Victor Olex
It is worth mentioning that Mike has published slides from his PyGotham talk on SQLAlchemy architecture, which also covered certain internal algorithms. http://techspot.zzzeek.org/2011/09/16/sqlalchemy-at-pygotham/ I am looking forward to watching the video, which should help me get a grasp of

[sqlalchemy] Re: PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-20 Thread Victor Olex
.    Overall the status of ODBC on unix is extremely concerning to me as there doesn't seem to be anyone around to help with anything. On Sep 12, 2011, at 3:27 PM, Victor Olex wrote: I confirm successful build and run time on both 64-bit and 32-bit Linux (RHEL5) againt SQL Server 2008

[sqlalchemy] different behavior with schema qualified tables in sqlite since 0.7.x

2011-09-16 Thread Victor Olex
not occur. Neither SQLite nor pysqlite version have changed. -- Victor Olex http://linkedin.com/in/victorolex http://twitter.com/agilevic -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy

[sqlalchemy] Re: PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-12 Thread Victor Olex
of the CPPFLAGS=-DBUILD_LEGACY_64_BIT_MODE - DSIZEOF_LONG_INT=8 allowed me to align the libs to the Pyodbc such that the segfault got eliminated but in the end the flags proved unneccesary once the above mentioned include path was properly set. On Sep 9, 10:54 pm, Victor Olex victor.o...@vtenterprise.com

[sqlalchemy] Re: PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-09 Thread Victor Olex
What version of pyodbc? On Sep 9, 11:08 am, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 9, 2011, at 10:48 AM, Michael Bayer wrote: It also makes me less than comfortable unconditionally emitting a u'' for a bound parameter as it appears to cause problems. I've also checked my

[sqlalchemy] Re: PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-09 Thread Victor Olex
and tried that one too. Has pyodbc made adjustments to changes in FreeTDS 0.91 ? On Sep 9, 2011, at 1:15 PM, Victor Olex wrote: What version of pyodbc? On Sep 9, 11:08 am, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 9, 2011, at 10:48 AM, Michael Bayer wrote: It also makes me less

[sqlalchemy] Re: PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-08 Thread Victor Olex
vary based on architecture At run time be sure to have the LD_LIBRARY_PATH and TDSVER=8.0 variables set. The latter is not needed if you put the same into connection string as I have in the example above. I hope this helps. Victor Olex http://linkedin.com/in/victorolex http://twitter.com/agilevic

[sqlalchemy] Re: PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-08 Thread Victor Olex
/userguide/config.htm On Sep 8, 10:32 am, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 8, 2011, at 9:37 AM, Victor Olex wrote: I never for a moment thought that your change was thoughtless. To the contrary, I have huge respect for SQLAlchemy. I will try to test the drop_all and your

[sqlalchemy] Re: PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-08 Thread Victor Olex
, Victor Olex wrote: Pyodbc issue 209 works fine in my setup. that is very strange ?   There are files missing from the .zip.  If you installed from the zip I don't see how it built for you.  Here's the original issue: http://code.google.com/p/pyodbc/issues/detail?id=192 I think

[sqlalchemy] Re: Question on session.expunge.all()

2011-09-08 Thread Victor Olex
Since you are effectively overwriting the table with new file contents, the fastest may well be to truncate the table then insert all contents. If you were to just append and update then session.merge() is convenient way to do this though I am not sure if the fastest. On Sep 7, 5:53 pm, Vlad K.

[sqlalchemy] Re: PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-08 Thread Victor Olex
? On Sep 8, 2011, at 12:41 PM, Victor Olex wrote: I know of those issues with pyodbc package. Michael, please read my first response where I wrote how to build the unixODBC, FreeTDS and pyodbc stack. I gave this detail for a reason - i.e. that you can replicate my built. By the way I did

[sqlalchemy] Re: PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-08 Thread Victor Olex
wrote: thanks, the two test failures would be expected in this case, will see what response I get on the FreeTDS list if any. On Sep 8, 2011, at 3:07 PM, Victor Olex wrote: Unfortunately I don't have access to a blank database and I took the chance and ran your tests on a non-empty database

[sqlalchemy] PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-07 Thread Victor Olex
correctly as does the in memory object. Different version combinations of pyodbc, FreeTDS and SQL may likely yield a different result so unless a deterministic factor is found I would like to propose adding parameter bind_unicode to dialect class and connection url. Regards and respect, Victor Olex http

[sqlalchemy] Re: on padded character fields again

2010-09-15 Thread Victor Olex
): return value.rstrip() On Sep 14, 11:49 am, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 14, 2010, at 11:42 AM, Victor Olex wrote: We have discussed one aspect of this before and it was hugely helpful (http://groups.google.com/group/sqlalchemy/browse_thread/thread

[sqlalchemy] dealing with multiple databases when using declarative

2009-12-03 Thread Victor Olex
By database we refer to a separate instance (could be on another server) of equvalent database i.e. production and development environments. Using sqlalchemy.ext.declarative, what would be a correct pattern to enable one model to connect to two equivalent databases? Consider: --- model.py ---