If the datatype of in database is Varchar its working fine, error comes
only with integer. Any help here is highly appreciated.
Best Regards,
Nikhil
On Sunday, 31 July 2016 22:28:27 UTC+5:30, Nikhil S Menon wrote:
>
> i am using *SQLAlchemy-1.0.5.*
>
>
> i have an external db with a table having integer. while i run the select
> query i am getting below error.
>
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
>
> line 914, in execute
> return meth(self, multiparams, params)
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
>
> line 323, in _execute_on_connection
> return connection._execute_clauseelement(self, multiparams, params)
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
>
> line 1010, in _execute_clauseelement
> compiled_sql, distilled_params
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
>
> line 1146, in _execute_context
> context)
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
>
> line 1334, in _handle_dbapi_exception
> self._autorollback()
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
>
> line 791, in _autorollback
> self._root._rollback_impl()
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
>
> line 670, in _rollback_impl
> self._handle_dbapi_exception(e, None, None, None, None)
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
>
> line 1266, in _handle_dbapi_exception
> exc_info
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py",
>
> line 202, in raise_from_cause
> reraise(type(exception), exception, tb=exc_tb, cause=cause)
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
>
> line 668, in _rollback_impl
> self.engine.dialect.do_rollback(self.connection)
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py",
>
> line 420, in do_rollback
> dbapi_connection.rollback()
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/pg8000/core.py", line
> 1751, in rollback
> self.execute(self._cursor, "rollback", None)
> File
> "/home/nfs/nikhil/local/lib/python2.7/site-packages/pg8000/core.py", line
> 2016, in execute
> self._flush()
> File "/usr/lib/python2.7/socket.py", line 303, in flush
> self._sock.sendall(view[write_offset:write_offset+buffer_size])
> sqlalchemy.exc.DBAPIError: (exceptions.AttributeError) 'NoneType' object
> has no attribute 'sendall'
> No handlers could be found for logger "sqlalchemy.pool.QueuePool"
>
>
> *sqlalchemy.exc.DBAPIError: (exceptions.AttributeError) 'NoneType' object
> has no attribute 'sendall'*
>
>
> *from sqlalchemy import **
> *def connect_db(db):*
> *
> engine=create_engine('postgresql+pg8000://[email protected]:5432/%s'%db)*
> * return engine*
>
> *def load_table(table_name):*
> * table_data = Table(table_name, m, autoload=True,
> autoload_with=engine)*
> * return table_data*
>
> *def get_all_tables_data():*
> * m.reflect(bind=engine)*
> * for table in m.tables:*
> * print "%s\n---------\n"%table*
> * table_data = load_table(table)*
> * q = select([table_data])*
> * print q*
> * res = conn.execute(q)*
> * for row in res:*
> * print row*
> *engine = connect_db("db")*
> *m = MetaData(engine)*
> *conn = engine.connect()*
> *get_all_tables_data()*
>
>
> Its happening with external database only when I use the sqlalchemy
> library in python. If i use postgres shell its working. Please find below
> details from postgres interface.
>
> db=# \d mas_license;
> Table "public.mas_license"
> Column | Type | Modifiers
> ----------------+-------------------+-----------
> id | character varying | not null
> node_id | character varying |
> rpt_sampletime | bigint |
> max_vips | character varying |
> pooled_lic | integer |
> cpx_lic | integer |
> perf | integer |
> snmp_traps | integer |
> syslog | integer |
> analytics | integer |
> adv_analytics | integer |
> Indexes:
> "mas_license_pkey" PRIMARY KEY, btree (id)
>
> =# select * from mas_license;
> id | node_id | rpt_sampletime |
> max_vips | pooled_lic |
> cpx_lic | perf | snmp_traps | syslog | analytics | adv_analytics
>
> --------------------------------------+---------+----------------+------------------------------------------------------------------+------------+---------+------+------------+--------+-----------+---------------
> 5-34 | | 1469625865 | f6f6-34437c | 1 | 1 |
> 3 | 3 | 3 | 3 | 1
> (1 row)
>
> Using pgxl as external database.
>
>
> Best Regards,
> Nikhil
>
--
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.