[This message has also been posted.]
On Fri, 9 Oct 2009 13:28:58 -0400, Michael Bayer
<mike...@zzzcomputing.com> wrote:

> did you commit your transaction  or set autocommit=True in your text()
> statement ?   that string you have will not trip off SQLA's "autocommit"
> feature.

Hi,

Thanks for the explanation. No, the code I used is exactly as written,
modulo the db string. which was of the form
postgres://dbuser:pas...@localhost:5432/dbname

I see that the documentation for

sqlalchemy.sql.expression.text

has an option

autocommit=True
    indicates this SELECT statement modifies the database, and should
    be subject to autocommit behavior if no transaction has been
    started.

I missed this, since I assumed that the cursor object would have such
a option, which does not appear to be the case. I've confirmed adding
this option to the text string fixes the problem.

Can you explain why removing the "SET search_path TO public;" string
makes a commit happen? You also say "that string you have will not
trip off SQLA's "autocommit" feature." How does this autocommit
feature work, and are there certain strings that will trigger an
autocommit?

                                                     Regards, Faheem.

> Faheem Mitha wrote:
>>
>> Confirmed by Alex Grönholm on #postgresql on freenode with pg 8.3 and sqla
>> 0.5.6. If this is not a bug, i'd like to know what is going on. Typing the
>> text in gq directly into psql (all on one line) produces the schema foo as
>> expected.
>>
>>                                                            Regards,
>> Faheem.
>>
>> btsnp=# \dn
>>          List of schemas
>>          Name        |  Owner
>> --------------------+----------
>>   information_schema | postgres
>>   pg_catalog         | postgres
>>   pg_toast           | postgres
>>   pg_toast_temp_1    | postgres
>>   public             | postgres
>> (5 rows)
>>
>> btsnp=# SET search_path TO public; DROP SCHEMA IF EXISTS foo CASCADE;
>> CREATE SCHEMA foo;
>> SET
>> NOTICE:  schema "foo" does not exist, skipping
>> DROP SCHEMA
>> CREATE SCHEMA
>> btsnp=# \dn
>>          List of schemas
>>          Name        |  Owner
>> --------------------+----------
>>   foo                | faheem
>>   information_schema | postgres
>>   pg_catalog         | postgres
>>   pg_toast           | postgres
>>   pg_toast_temp_1    | postgres
>>   public             | postgres
>> (6 rows)
>>
>> On Wed, 7 Oct 2009, Faheem Mitha wrote:
>>
>>>
>>> Hi,
>>>
>>> When running this function with postgresql 8.4 and sqla 0.5.5,
>>>
>>> def test(dbstring):
>>>   from sqlalchemy import create_engine
>>>   db = create_engine(dbstring)
>>>   conn = db.connect()
>>>   from sqlalchemy.sql import text
>>>   gq = text("""
>>>   SET search_path TO public;
>>>   DROP SCHEMA IF EXISTS foo CASCADE;
>>>   CREATE SCHEMA foo;
>>>   """)
>>>   conn.execute(gq)
>>>   conn.close()
>>>
>>> the schema foo is not created. However, removing the
>>>
>>> SET search_path TO public;
>>>
>>> line makes it work. This is not the case when issuing these commands
>>> directly
>>> via psql. Any idea what might be going on here?
>>>
>>>                                                     Regards, Faheem.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to