[sqlalchemy] inspection does not update mapper schema when schema assigned to declarative during runtime

2020-07-02 Thread Peter Lai
It appears that if during runtime I assign a schema to declarative, then `inspect()` it, the resulting Selectable does not have the schema assigned to it: in model.py: from sqlalchemy import Column, String, DateTime from sqlalchemy.ext.declarative import declarative_base Base =

[sqlalchemy] Pyodbc creator function ignored in create_engine (mssql)

2020-05-22 Thread Peter Lai
example: import pyodbc from sqlalchemy import create_engine def creator(): config = { 'driver': 'ODBC Driver 13 for SQL Server', 'host': 'localhost', 'port': 1433, 'user': 'me', 'pw': 'mypw', 'dbname': 'mydb' } return

Re: [sqlalchemy] Any way to suppress CASTs during Concrete Inheritance unions on Oracle ?

2018-06-13 Thread Peter Lai
On Wednesday, June 13, 2018 at 8:28:32 PM UTC-4, Mike Bayer wrote: > > On Wed, Jun 13, 2018 at 7:44 PM, Peter Lai > wrote: > > I've implemented a Concrete inheritance model and Oracle 11g is balking > on > > `CAST(NULL AS CLOB) as fieldn` during the pjo

[sqlalchemy] Any way to suppress CASTs during Concrete Inheritance unions on Oracle ?

2018-06-13 Thread Peter Lai
I've implemented a Concrete inheritance model and Oracle 11g is balking on `CAST(NULL AS CLOB) as fieldn` during the pjoin union query execution with: ORA-00932: inconsistent datatypes: expected - got CLOB This happens when the unioned tables representing the 2 subclasses have different `Text`

Re: [sqlalchemy] How to create multiple TABLES and INSERTS programatically ?

2018-04-03 Thread Peter Lai
I wonder if one can also do this with Declarative Base classes using `type` construction? Like, to dynamically create a Declarative Class from some pre-defined namespace dicts: Base = declarative_base() metas = [{'__tablename__': 'footable'}, ...] columns = [{ 'key': 'field1', 'type': Text},

[sqlalchemy] Differentiate what raised IntegrityError (fkey not found vs. duplicate pkey)

2018-03-20 Thread Peter Lai
I'm implementing a recursive upsert operation for an object whose primary key also contains a foreignkey, and I'd like to get some more info from IntegrityError, namely whether integrity was violated because the foreignkey didn't exist (yet) or I am trying to insert a duplicate pkey. In the

[sqlalchemy] Re: base class not inserting correctly on subclass insertion (joined table inheritance)

2018-03-20 Thread peter . lai
Yeah it took me about 3 hours to realize that in my actual code, I made a typo in the __init__ so that I was assigning the uuid to the wrong attribute/column. So embarassing :( On Monday, March 19, 2018 at 11:04:04 PM UTC-4, Peter Lai wrote: > > As seen at: > https://stackove