[sqlalchemy] Case Sensitivity at query time for SQL Server

2019-05-17 Thread Massi
Hi, I'm trying to issue a query in SQL Server via select(cols, cond, ...) and I would like to add collation at query execution time for executing the query in a case sensitive mode. I tried this: cond = and_(tab.c.col3=="mystring1", tab.c.col2=="mystring2") cond =

[sqlalchemy] PostgreSQL: problem with simple rowqcount query

2015-09-04 Thread Massi
HI everyone, I'm trying to use sqlalchemy (0.9.10) to retrieve the number of rows of table in PostgreSQL, here a stub of the code: import sqlalchemy from sqlalchemy import select, create_engine, MetaData, Table, Column import datetime engine =

Re: [sqlalchemy] sqlite problem with datetime format YYYY-MM-DDTHH:mm:ss

2015-09-03 Thread Massi
sions/declarative/table_config.html#using-reflection-with-declarative > > > Simon > > On Thu, Sep 3, 2015 at 3:54 PM, Massi <mass...@msn.com > > wrote: > > Hi Simone, > > > > thank you for your reply. Unfortunately I don't create the table so I > d

Re: [sqlalchemy] sqlite problem with datetime format YYYY-MM-DDTHH:mm:ss

2015-09-03 Thread Massi
t 1:05 PM, Massi <mass...@msn.com > > wrote: > > Hi everyone, > > > > I'm trying to use sqlalchemy (0.9.10) to read a sqlite table which > contains > > some datetime columns. As the title says these column are given in the > > format -MM-DDTHH:mm

[sqlalchemy] sqlite problem with datetime format YYYY-MM-DDTHH:mm:ss

2015-09-03 Thread Massi
Hi everyone, I'm trying to use sqlalchemy (0.9.10) to read a sqlite table which contains some datetime columns. As the title says these column are given in the format -MM-DDTHH:mm:ss (I did not create the table). When I execute the query, it succeeds, but when I try to convert the rows to

Re: [sqlalchemy] Error with SQL Server and utf-8 encoding

2015-09-02 Thread Massi
It works! Thanks a lot! On Tuesday, September 1, 2015 at 5:42:08 PM UTC+2, Michael Bayer wrote: > > > > On 9/1/15 11:28 AM, Massi wrote: > > Hi everyone, > > I'm trying to manage read and write operations of utf-8 unicode strings > with SQL Server (sqlalchemy 0

[sqlalchemy] Error with SQL Server and utf-8 encoding

2015-09-01 Thread Massi
Hi everyone, I'm trying to manage read and write operations of utf-8 unicode strings with SQL Server (sqlalchemy 0.9.10), but I'm having some problems. I correctly write the strings to the database, but when I read them back and try to convert to unicode I get the following error: Traceback

[sqlalchemy] MySql+oursql error on Time columns

2015-08-31 Thread Massi
Hi everyone, I'm trying to use oursql module with sqlalchemy (0.9.10) for managing a table with TIME columns, but I'm encountering an error, here a code snippet showing the problem: import sqlalchemy from sqlalchemy import select, create_engine, MetaData, Table, Column import datetime engine

[sqlalchemy] SQLAlchemy and Linked Server (SQL Server)

2014-05-26 Thread Massi
Hi everyone, I'm trying to access data from a linked server using SQLalchemy (0.9.4), The usual connection established via pyodbc (engine = create_engine( 'mssql+pyodbc://scott:tiger@mydsn')) does not seem to work. Actually I can only read the data with SQL Server using SQL Management Studio

Re: [sqlalchemy] Problem inserting records in blob column

2013-12-20 Thread Massi
Hi, I'm experiencing a similar problem in my program (Sqlalchemy 0.8.4). In my case no blob column is involved, the problem seems to be related to presence of a foreign key in the target table. Here is the traceback of the error: File C:\Python27\lib\site-packages\sqlalchemy\orm\session.py,

[sqlalchemy] column_mapped_collection and insertion order preservation

2013-03-10 Thread Massi
Hi everyone, in my script I'm using column_mapped_collection to create a collection indexed by a column of a certain table. This is an example scenario (pseudo code): class Parent(object): def __init__(self): # define some fileds def AddChild(self, new_child):

[sqlalchemy] Sqlalchemy issue on Windows Server 2008 R2 sp1

2012-11-27 Thread Massi
Hi everyone, as the title says I'm trying to run sqlalchemy (pyodbc) with SQL Server 2008 on Windows Server 2008 R2 sp1 but I'm failing with the database connection. Here is a small script I'm using to test the connection: from sqlalchemy import * from sqlalchemy.engine import reflection url

[sqlalchemy] Double quoted name column problem (Sqlite)

2012-09-18 Thread Massi
Hi everyone, I'm using sqlalchemy 0.7.8 with sqlite and I'm encountering a problem trying to retrieve data from a table having a column named input_1. If I run this simple code: from sqlalchemy import * db = create_engine('sqlite:///test.db') db.echo = False metadata = MetaData(db) t =

[sqlalchemy] Re: Double quoted name column problem (Sqlite)

2012-09-18 Thread Massi
double quotes with a blank. Is this really necessary? Does there exist any workaround to overcome this problem? Il giorno martedì 18 settembre 2012 18:21:36 UTC+2, Massi ha scritto: Hi everyone, I'm using sqlalchemy 0.7.8 with sqlite and I'm encountering a problem trying to retrieve data from

[sqlalchemy] How to (quick) check if a table exists in schema?

2012-04-25 Thread Massi
Hi everyone, in my script I have to deal with a huge database with thousands of tables. Given a table name (a python string) I would have to now if such a table exists or not. Up to now I have written this function: def DBGetTableByName(table_name) : metadata = MetaData(engine)

[sqlalchemy] Re: How to (quick) check if a table exists in schema?

2012-04-25 Thread Massi
that the resulting vector is ordered. Am I wrong? Other Ideas? On 25 Apr, 16:11, Wichert Akkerman wich...@wiggy.net wrote: On 04/25/2012 03:57 PM, Massi wrote: Hi everyone, in my script I have to deal with a huge database with thousands of tables. Given a table name (a python

[sqlalchemy] Re: InsertFromSelect on SQL server

2011-08-19 Thread Massi
the 'postfetch' error. On 18 Ago, 19:34, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 18, 2011, at 1:19 PM, Massi wrote: I got:  File C:\Python26\lib\site-packages\sqlalchemy-0.7.2-py2.6-win32.egg \sqlalchemy\engine\base.py, line 2285, in execute    return connection.execute(statement

[sqlalchemy] InsertFromSelect on SQL server

2011-08-18 Thread Massi
Hi everyone, I'm trying to implement an InsertFromSelect workaround to handle the identity insert issue of SQL server. This is more or less what I'm doing: class InsertFromSelect(Executable, ClauseElement) : def __init__(self, table, select) : self.table = table self.select =

[sqlalchemy] Re: InsertFromSelect on SQL server

2011-08-18 Thread Massi
has no attribute '_returning' (original cause: AttributeError: 'InsertFromSelect' object has noattribute '_returning') 'INSERT INTO...' On 18 Ago, 18:34, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 18, 2011, at 12:24 PM, Massi wrote: Hi everyone, I'm trying to implement

[sqlalchemy] Re: InsertFromSelect on SQL server

2011-08-18 Thread Massi
, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 18, 2011, at 1:06 PM, Massi wrote: I changed the code to (SA 0.7.2 with pyodbc2.1.9): class InsertFromSelect(Executable, ClauseElement) :    _execution_options =\ Executable._execution_options.union({'autocommit': True})    def

[sqlalchemy] Simple select is really slow when executed via ORM

2011-08-12 Thread Massi
Hi everyone, I'm doing some test to evaluate the performance of querying with sqlalchemy via ORM. I wrote a simple script to measure the execution time of a simple select query made on relatively small table (300 000 records, 6 columns) in sqlite. Here is the script: from sqlalchemy import *

[sqlalchemy] Ho do I syncronize ORM objects when working with multiple sessions?

2011-08-11 Thread Massi
Hi everyone, in my script I work with two different sessions (say session1 and session2) bounded to the same database and, consequently, with ORM objects obtained with queries issued on them. It can occur that an object related to session1 change a value of the corresponding mapped table record

[sqlalchemy] SQL Server weird sorting behaviour

2011-07-14 Thread Massi
Hi everyone, I'm using sqlalchemy 0.6.8 to interact with an sql server database via pyodbc. I'm getting in troubles using the 'order by' clause on a varchar column which include positive or negative integer values. When I try to get values from this column ordered in ascending mode I get: 1 -1 11

[sqlalchemy] Strange Error: FlushError: Instance Child at 0x1087b30 has a NULL identity key.

2011-05-22 Thread Massi
Hi everyone, I'm writing a script using sqlalchemy 0.66 and sqlite3. In my script I'm trying to set up a one to one relation between two tables via ORM. Here is a simplified code showing my situation: from sqlalchemy import * from sqlalchemy.orm import * class Parent(object) : def

[sqlalchemy] Sqlalchemy+sqlite3 autoload problem

2011-04-07 Thread Massi
Hi everyone, I'm writing a script using sqlalchemy 0.66 and sqlite3. I'm encountering a problem trying to create and load a table from two different engines. Here is an example script showing the problem: from sqlalchemy import * engine1 = create_engine(sqlite:///test.db, echo=False) metadata1 =

[sqlalchemy] Simple problem with SQLite and Standard Deviation

2011-03-28 Thread Massi
Hi everyone, I'm using sqlalchemy 0.6.6 with SQLite...my problem is simple, is there a way to compute standard deviation in sqlalchemy with SQlite as a backend? I googled and found that native SQLite does not support any aggregate function like MySQL 'stdev', but there exist some extensions which

[sqlalchemy] Sqlalchemy+Kinterbasdb installation error

2011-02-28 Thread Massi
Hi everyone, I'm trying to access a Firebird (version 2.5) database through Kinterbasdb under windows 7 with python 2.6. I'have download the file: kinterbasdb-3.3.0.win32-py2.6.msi which can be found at this link: http://www.firebirdsql.org/index.php?op=develsub=python, but when I try to

[sqlalchemy] SqlAlchemy+cx_oracle decimal point problem with stddev

2011-02-22 Thread Massi
Hi everyone, in my script (python 2.6, Oracle10g, cx_oracle 5.0.4, sqlalchemy 0.6.5) I'm running the following simple query on one of my tables: table = Table(my_data_table, metadata, autoload=True) col = getattr(table.c, my_integer_col) res = select(func.stdev(col)).execute().fetchone() where

[sqlalchemy] Clearing an already defined mapper

2011-01-24 Thread Massi
Hi everyone, in my script I have to deal with a table whose number of columns can change at runtime. Since I have no information about the structure I will have to handle at a given moment, I would need to change dynamically the mapping during the program. If I try to re-map the table I obviously

[sqlalchemy] Problem updating mapped child class

2010-10-25 Thread Massi
Ok, the title doesn't say much, so I'll try to explain my problem with an example: I have two classes: class A(object) : pass class B(object) : pass which are bounded by a relation: a_tab = Table(...) b_tab = Table(...) b_tab.append_constraint(ForeignKeyConstraint([a_tab.c.id],

[sqlalchemy] Newbie problem with relational mapping

2010-09-08 Thread Massi
Hi everyone, I'm getting in troubles doing some experiments with sqlalchemy (0.6.3) orm. Here are two code snippets to show the problems I'm encountering. ## map_1.py engine = create_engine(mysql://user:passw...@localhost/mydb) metadata = MetaData(engine) parent_table = Table('parent', metadata,

[sqlalchemy] Making a copy of a table

2010-07-28 Thread Massi
Hi everyone, I'm getting in trouble in th attempt to create a simple copy (structure and data) of a table in my database (sql server). I need the SQLAlchemy equivalent of the query: SELECT * INTO newtable FROM table How can I achieve this? I found that tometadata probably could do the trick,

[sqlalchemy] SQLAlchemy+pymssql unicode problem

2010-07-23 Thread Massi
Hi everyone, I'm trying to write a small script to get all the table names from SQLServer database (with pymssql). Up to now the script is really simple: engine = create_engine(mssql+pymssql://user:passw...@db_host/ db_name, encoding=cp1252) metadata = MetaData(engine, reflect=True) tabs =