Re: [sqlalchemy] Session.add doesn't work on Python 3.3.0?

2013-04-16 Thread Mauricio de Abreu Antunes
I tried your same code here I got True.

Em terça-feira, 16 de abril de 2013, Michael Bayer escreveu:

> cant reproduce, running with Python 3.3.0 here against 0.8.0 I get the
> INSERT:
>
> PRAGMA table_info("products")
> 2013-04-16 16:14:41,019 INFO sqlalchemy.engine.base.Engine ()
> 2013-04-16 16:14:41,019 INFO sqlalchemy.engine.base.Engine
> CREATE TABLE products (
> id INTEGER NOT NULL,
> name VARCHAR(200),
> description TEXT,
> PRIMARY KEY (id)
> )
>
>
> 2013-04-16 16:14:41,020 INFO sqlalchemy.engine.base.Engine ()
> 2013-04-16 16:14:41,020 INFO sqlalchemy.engine.base.Engine COMMIT
> True
> 2013-04-16 16:14:41,021 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
> 2013-04-16 16:14:41,021 INFO sqlalchemy.engine.base.Engine INSERT INTO
> products (id, name, description) VALUES (?, ?, ?)
> 2013-04-16 16:14:41,021 INFO sqlalchemy.engine.base.Engine (1, 'Test',
> 'Test')
> 2013-04-16 16:14:41,022 INFO sqlalchemy.engine.base.Engine COMMIT
> 2013-04-16 16:14:41,022 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
> 2013-04-16 16:14:41,022 INFO sqlalchemy.engine.base.Engine SELECT
> products.id AS products_id, products.name AS products_name,
> products.description AS products_description
> FROM products
> 2013-04-16 16:14:41,023 INFO sqlalchemy.engine.base.Engine ()
> [<__main__.Product object at 0x105c3dbd0>]
>
>
>
> On Apr 16, 2013, at 2:42 PM, Tim Cooijmans  wrote:
>
> from sqlalchemy import create_engine, Integer, String, Text, Column, 
> Sequence, DateTime, ForeignKeyfrom sqlalchemy.orm import sessionmaker, 
> relationship, backreffrom sqlalchemy.ext.declarative import declarative_base
>
> engine = create_engine("sqlite:///:memory:", echo=True)Session = 
> sessionmaker(bind = engine)Base = declarative_base()
>
>  --
> 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 sqlalchemy+unsubscr...@googlegroups.com  'cvml', 'sqlalchemy%2bunsubscr...@googlegroups.com');>.
> To post to this group, send email to 
> sqlalchemy@googlegroups.com 'sqlalchemy@googlegroups.com');>
> .
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
*Mauricio de Abreu Antunes*
Mobile: (51)930-74-525
Skype: mauricio.abreua

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] Session.add doesn't work on Python 3.3.0?

2013-04-16 Thread Michael Bayer
cant reproduce, running with Python 3.3.0 here against 0.8.0 I get the INSERT:

PRAGMA table_info("products")
2013-04-16 16:14:41,019 INFO sqlalchemy.engine.base.Engine ()
2013-04-16 16:14:41,019 INFO sqlalchemy.engine.base.Engine 
CREATE TABLE products (
id INTEGER NOT NULL, 
name VARCHAR(200), 
description TEXT, 
PRIMARY KEY (id)
)


2013-04-16 16:14:41,020 INFO sqlalchemy.engine.base.Engine ()
2013-04-16 16:14:41,020 INFO sqlalchemy.engine.base.Engine COMMIT
True
2013-04-16 16:14:41,021 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2013-04-16 16:14:41,021 INFO sqlalchemy.engine.base.Engine INSERT INTO products 
(id, name, description) VALUES (?, ?, ?)
2013-04-16 16:14:41,021 INFO sqlalchemy.engine.base.Engine (1, 'Test', 'Test')
2013-04-16 16:14:41,022 INFO sqlalchemy.engine.base.Engine COMMIT
2013-04-16 16:14:41,022 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2013-04-16 16:14:41,022 INFO sqlalchemy.engine.base.Engine SELECT products.id 
AS products_id, products.name AS products_name, products.description AS 
products_description 
FROM products
2013-04-16 16:14:41,023 INFO sqlalchemy.engine.base.Engine ()
[<__main__.Product object at 0x105c3dbd0>]



On Apr 16, 2013, at 2:42 PM, Tim Cooijmans  wrote:

> from sqlalchemy import create_engine, Integer, String, Text, Column, 
> Sequence, DateTime, ForeignKey
> from sqlalchemy.orm import sessionmaker, relationship, backref
> from sqlalchemy.ext.declarative import declarative_base
> 
> engine = create_engine("sqlite:///:memory:", echo=True)
> Session = sessionmaker(bind = engine)
> Base = declarative_base()
> 
> class Product(Base):
> __tablename__ = "products"
> 
> id = Column(Integer, primary_key=True)
> name = Column(String(200))
> description = Column(Text)
> 
> Base.metadata.create_all(engine)
> 
> session = Session()
> product = Product()
> product.id = 1
> product.name = "Test"
> product.description = "Test"
> 
> session.add(product)
> print(product in session) # Expected true
> session.commit()
> print(session.query(Product).all()) # Expected the previous item

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] Session.add doesn't work on Python 3.3.0?

2013-04-16 Thread Mauricio de Abreu Antunes
I think you need to commit your session data.

Em terça-feira, 16 de abril de 2013, Tim Cooijmans escreveu:

> I have a strange error using Python 3.3.0 and SQLAlchemy 0.8.0:
>
> from sqlalchemy import create_engine, Integer, String, Text, Column, 
> Sequence, DateTime, ForeignKeyfrom sqlalchemy.orm import sessionmaker, 
> relationship, backreffrom sqlalchemy.ext.declarative import declarative_base
>
> engine = create_engine("sqlite:///:memory:", echo=True)Session = 
> sessionmaker(bind = engine)Base = declarative_base()
> class Product(Base):
> __tablename__ = "products"
>
> id = Column(Integer, primary_key=True)
> name = Column(String(200))
> description = Column(Text)
> Base.metadata.create_all(engine)
>
> session = Session()
> product = Product()
> product.id = 1
> product.name = "Test"
> product.description = "Test"
>
> session.add(product)print(product in session) # Expected true
> session.commit()print(session.query(Product).all()) # Expected the previous 
> item
>
> As commented in code I expected the add method to add the product to the
> database using an INSERT. But it doesn't nor does it throw an exception.
> This is the log:
>
> 2013-04-16 18:03:14,368 INFO sqlalchemy.engine.base.Engine PRAGMA 
> table_info("products")2013-04-16 18:03:14,369 INFO 
> sqlalchemy.engine.base.Engine ()2013-04-16 18:03:14,371 INFO 
> sqlalchemy.engine.base.Engine
> CREATE TABLE products (
> id INTEGER NOT NULL,
> name VARCHAR(200),
> description TEXT,
> PRIMARY KEY (id))
>
> 2013-04-16 18:03:14,371 INFO sqlalchemy.engine.base.Engine ()2013-04-16 
> 18:03:14,371 INFO sqlalchemy.engine.base.Engine COMMITFalse2013-04-16 18:04
>
>

-- 
*Mauricio de Abreu Antunes*
Mobile: (51)930-74-525
Skype: mauricio.abreua

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sqlalchemy] Session.add doesn't work on Python 3.3.0?

2013-04-16 Thread Tim Cooijmans


I have a strange error using Python 3.3.0 and SQLAlchemy 0.8.0:

from sqlalchemy import create_engine, Integer, String, Text, Column, Sequence, 
DateTime, ForeignKeyfrom sqlalchemy.orm import sessionmaker, relationship, 
backreffrom sqlalchemy.ext.declarative import declarative_base

engine = create_engine("sqlite:///:memory:", echo=True)Session = 
sessionmaker(bind = engine)Base = declarative_base()
class Product(Base):
__tablename__ = "products"

id = Column(Integer, primary_key=True)
name = Column(String(200))
description = Column(Text)
Base.metadata.create_all(engine)

session = Session()
product = Product()
product.id = 1
product.name = "Test"
product.description = "Test"

session.add(product)print(product in session) # Expected true
session.commit()print(session.query(Product).all()) # Expected the previous item

As commented in code I expected the add method to add the product to the 
database using an INSERT. But it doesn't nor does it throw an exception. 
This is the log:

2013-04-16 18:03:14,368 INFO sqlalchemy.engine.base.Engine PRAGMA 
table_info("products")2013-04-16 18:03:14,369 INFO 
sqlalchemy.engine.base.Engine ()2013-04-16 18:03:14,371 INFO 
sqlalchemy.engine.base.Engine 
CREATE TABLE products (
id INTEGER NOT NULL, 
name VARCHAR(200), 
description TEXT, 
PRIMARY KEY (id))

2013-04-16 18:03:14,371 INFO sqlalchemy.engine.base.Engine ()2013-04-16 
18:03:14,371 INFO sqlalchemy.engine.base.Engine COMMITFalse2013-04-16 
18:04:04,706 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)2013-04-16 
18:04:04,708 INFO sqlalchemy.engine.base.Engine SELECT products.id AS 
products_id, products.name AS products_name, products.description AS 
products_description 
FROM products2013-04-16 18:04:04,709 INFO sqlalchemy.engine.base.Engine ()[]

I already tried several things:

   - Changing the engine doesn't work: I also tried postgresql.
   - I tried debugging. When I reach the body of the add method there is 
   nothing to step into.

Am I doing something wrong or is this a bug?
(Also posted this question on Stack Overflow: 
http://stackoverflow.com/questions/16041868/sqlalchemy-session-add-doesnt-work
)


-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.