On Fri, Jul 20, 2018 at 3:58 PM, Madhav Dube <[email protected]> wrote:
> It is not generating much of the stack trace. In one line it is just
> displaying this error message and no SQL gets fired.
then your program must be catching the error and not reporting it,
because plain Python would illustrate a stack trace of at least one
line that would show where in your program the ".uri" field is being
accessed. Using your program above, no error occurs. Here's a full
demonstration that actually prints something:
from sqlalchemy import MetaData, Column, Integer, Table
from sqlalchemy import create_engine
uri = 'postgresql://user:password@hostname/database_name'
def dump(sql, *multiparams, **params):
print(sql.compile(dialect=engine.dialect))
engine = create_engine(uri, strategy='mock', executor=dump)
metadata = MetaData()
t = Table('testtable', metadata,
Column('pk',
Integer,
primary_key=True))
t.create(engine)
t.drop(engine)
output as expected:
CREATE TABLE testtable (
pk SERIAL NOT NULL,
PRIMARY KEY (pk)
)
DROP TABLE testtable
that's with 1.2.10 as well as master.
If I actually try to access .url off of the MockConnection, which
doesn't exist, output shows where this is happening:
python test.py
Traceback (most recent call last):
File "test.py", line 12, in <module>
print(engine.url)
AttributeError: 'MockConnection' object has no attribute 'url'
need more information to fix your issue.
I am using Sqlalchemy
> version 1.2.10 on Ubuntu 16.
>
>
> On Friday, July 20, 2018 at 12:40:50 PM UTC-4, Madhav Dube wrote:
>>
>> I wish to create scripts containing the sql statements executed by
>> sqlalchemy during table/schema creations.
>>
>> from sqlalchemy import create_engine
>> uri ='postgresql://user:password@hostname/database_name'
>> def dump(sql, *multiparams, **params):
>> print(sql.compile(dialect=engine.dialect))
>> engine = create_engine(uri, strategy='mock', executor=dump)
>>
>>
>> It is throwing me an error.
>>
>> 'MockConnection' object has no attribute 'url'
>
> --
> 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
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
--
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 description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.