Hello there.
(first post to group)
I've been having a problem with an incorrect rowcount for ResultProxies
using Sqlite databases. Regardless of how many rows in the resultset, it
gives me a rowcount of "-1". Best demonstrated with an example:
from sqlalchemy import create_engine, __version__
from sqlalchemy.orm import create_session
print "Testing sqlite rowcount with SqlAlchemy v%s" % __version__
engine = create_engine('sqlite:///:memory:')
session = create_session(engine)
session.execute("""CREATE TABLE IF NOT EXISTS users (
id INT(8) NOT NULL,
status INT NOT NULL,
name VARCHAR(100) NULL,
PRIMARY KEY (id)
);""")
session.execute("INSERT INTO users (id, status, name) VALUES(1, 'Dan', 2)")
session.execute("INSERT INTO users (id, status, name) VALUES(2, 'Dave', 1)")
session.execute("INSERT INTO users (id, status, name) VALUES(3, 'Donald',
5)")
result = session.execute("SELECT * FROM users")
print result.rowcount
allrows = result.fetchall()
print len(allrows)
session.close()
Output is:
Testing sqlite rowcount with SqlAlchemy v0.5.8
*-1*
3
Is this a bug? Am I doing something wrong?
Regards,
Adam
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.