Re: [sqlalchemy] Using __getattr__ and __setattr__ with sqlalchemy

2018-03-29 Thread Tolstov Sergey
This is may fault, now function found __getattr__, but it cannot find '__sa_instance_state' in self.__dict__ self.__class__.__dict__ it will raise Max recursive eror import datetime sl_starttime= datetime.datetime.utcnow() import copy import collections import datetime import enum import json im

Re: [sqlalchemy] Using __getattr__ and __setattr__ with sqlalchemy

2018-03-29 Thread Tolstov Sergey
import datetime sl_starttime= datetime.datetime.utcnow() import copy import collections import datetime import enum import json import flask import sqlalchemy import sqlalchemy.ext.declarative import sqlalchemy.orm import sqlalchemy.orm.query import sqlalchemy.sql import sqlalchemy.types import sy

Re: [sqlalchemy] Using __getattr__ and __setattr__ with sqlalchemy

2018-03-29 Thread Tolstov Sergey
import datetime sl_starttime= datetime.datetime.utcnow() import copy import collections import datetime import enum import json import flask import sqlalchemy import sqlalchemy.ext.declarative import sqlalchemy.orm import sqlalchemy.orm.query import sqlalchemy.sql import sqlalchemy.types import sy

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Mike Bayer
sure but you need to know the structure of those tables. you might want to see if there's a tool that already exists for this database which does this. it seems to be heavy on the JDBC side so perhaps there are java tools that do it. On Thu, Mar 29, 2018 at 10:59 AM, Maki wrote: > In your knowl

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Maki
In your knowledge do you think there is a way to use pyodbc to copy all the tables and data in the table in the datasource to ms sql server and then after copying it in the sql server use SQLAlchemy for further process? Am Donnerstag, 29. März 2018 16:54:29 UTC+2 schrieb Mike Bayer: > > On Thu,

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Mike Bayer
On Thu, Mar 29, 2018 at 10:46 AM, Maki wrote: > I would love to code a new dialect for SQLAlchemy but i guess my python > skills are not there yet just started to learn python a few months ago. > What i dont understand is why i can connect to that Datasource using > pyodbc.connect(mydsn) with no p

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Maki
I would love to code a new dialect for SQLAlchemy but i guess my python skills are not there yet just started to learn python a few months ago. What i dont understand is why i can connect to that Datasource using pyodbc.connect(mydsn) with no problems but SQLAlchemy cant? Is there any other way

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Mike Bayer
OK this database is an entirely distinct product that has no particular resemblance to SQL server or anything else.You'd have to create your own dialect for this. The most fundamental thing to get working with a dialect is how to fetch identity values for integer primary keys, for this databa

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Maki
Hi Mike, here is the information about Cache Monitor. Its likely similar to MSSQL thats why i used the msql+pyodbc dialect. https://www.cachemonitor.de/ Secondly about the print(pyodbc_connection.getinfo(pyodbc.SQL_DBMS_VER)) ==> *OUTPUT: Cache Objects Version 2012.2.5.962 Cache xDBC Server 8.

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Mike Bayer
On Thu, Mar 29, 2018 at 9:18 AM, Maki wrote: > Hi Mike! > > I think there's a misunderstanding. Im trying to connect to a InterSystem > Cache Database thru ODBC (Datasource) but my MS SQL Server Management Studio > has this version (12.0.5207.0) oh, so the "InterSystem Cache Database", which I'v

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Maki
What i think is, in Cache Monitor Database there is no such thing as: SELECT CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR) Not like in a MSSQL Server. Im looking for ways to get the SERVERPROPERTY ProductVersion in Cache Monitor Database. Cant find how to query that in a Cache Monitor Datab

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Maki
Hi Mike! Both gives me the following error message: Traceback (most recent call last): File "db_test.py", line 17, in cursor.execute("SELECT CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR)") pyodbc.Error: ('HY000', "[HY000] [Cache ODBC][State : HY000][Native Code 359]\r\n[C:\\Users\\m.

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Mike Bayer
missing a dot: import pyodbc pyodbc_connection = pyodbc.connect(...) print(pyodbc_connection.getinfo(pyodbc.SQL_DBMS_VER)) On Thu, Mar 29, 2018 at 9:29 AM, Mike Bayer wrote: >> I render the code in pyodbc.py and add the pass to the except clause but it >> doesnt help getting the same error

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Mike Bayer
> I render the code in pyodbc.py and add the pass to the except clause but it > doesnt help getting the same error message with the str and int like before. OK that may suggest that it is falling back to the base pyodbc version management, so here is the updated patch: diff --git a/lib/sqlalchem

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Maki
Hi Mike! I think there's a misunderstanding. Im trying to connect to a *InterSystem Cache Database thru ODBC* (Datasource) but my *MS SQL Server Management Studio* has this version (12.0.5207.0) I render the code in pyodbc.py and add the pass to the except clause but it doesnt help getting the

Re: [sqlalchemy] Using __getattr__ and __setattr__ with sqlalchemy

2018-03-29 Thread Mike Bayer
send a complete MCVE please On Thu, Mar 29, 2018 at 2:08 AM, Tolstov Sergey wrote: > Before update it worked. But today i have a exception AttributeError: type > object 'Base' has no attribute '__getattr__' > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www

Re: [sqlalchemy] SQLAlchemy with DSN InterSystems ODBC35

2018-03-29 Thread Mike Bayer
Hi - unfortunately the stack trace indicates a bug in SQLAlchemy in that it is not interpreting your database's version string correctly. can you please provide me with the output of: SELECT CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR) Additionally, the likely cause of your issue can be w

[sqlalchemy] Re: Using __getattr__ and __setattr__ with sqlalchemy

2018-03-29 Thread Tolstov Sergey
def __getattr__ (self2, key2): if False: pass elif key2 == "attr_new": self2.attr_new = sqlalchemy.Column(UUID, sqlalchemy. ForeignKey(self.RELATED_CLASS.mRID), nullable = True) else: return getattr(self2.__class__, key2)

Re: [sqlalchemy] Using __getattr__ and __setattr__ with sqlalchemy

2018-03-29 Thread Tolstov Sergey
Solved, return getattr(self2.__class__, key2) -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full

Re: [sqlalchemy] rollback() practice

2018-03-29 Thread Simon King
On Thu, Mar 29, 2018 at 8:57 AM, wrote: > Hello, > > I had some database problems (unfinished transactions) so I have wrapped > sqlalchemy database handling functions in following way: > > def add(entry, session): > """Wrapper for db_session.add""" > try: > return session.add(entr

[sqlalchemy] rollback() practice

2018-03-29 Thread l00p1n6
Hello, I had some database problems (unfinished transactions) so I have wrapped sqlalchemy database handling functions in following way: def add(entry, session): """Wrapper for db_session.add""" try: return session.add(entry) except Exception as e: session.rollback()