[sqlalchemy] User configured models/attributes from the database

2019-11-27 Thread Alan Evans
In a typical flask app one defines their models in a models.py or some such. But what if I want my end user to be able to design some of the models too? Consider an asset tracking application for example. I could try to model every conceivable asset a business might want to track or I could

Re: [sqlalchemy] Problems reflecting "dbo" schema dynamically (ORM) in MS SQL Server

2019-11-27 Thread Mike Bayer
right so, automap requires that the tables have primary key constraints on them, otherwise they won't show up as mapped classes. So you'd need to define the declarative classes you are interested in and establish which columns would be used for primary keys on each if there is no primary key

Re: [sqlalchemy] Problems reflecting "dbo" schema dynamically (ORM) in MS SQL Server

2019-11-27 Thread Felipe Araya Olea
One thing I forgot to mention. This is not my personal database, this is my company's database, so maybe there are some restrictions and permissions that might play a part, although, if I use the engine as it is, it works, if I change even the smallest thing, I get an error saying access

Re: [sqlalchemy] Problems reflecting "dbo" schema dynamically (ORM) in MS SQL Server

2019-11-27 Thread Felipe Araya Olea
Hello Mike, Thanks for replying so quickly, I appreciate that. Below is the engine I am using and the output of the code you mentioned: params = urllib.parse.quote_plus('Driver={SQL Server};'\ "Server=***;"\

Re: [sqlalchemy] Problems reflecting "dbo" schema dynamically (ORM) in MS SQL Server

2019-11-27 Thread Mike Bayer
On Wed, Nov 27, 2019, at 2:45 PM, Felipe Araya Olea wrote: > Hello, > > I am having problems reflecting my tables from the MS SQL Server database > that have the schema "dbo". I have tried using the following code. "dbo" is the default schema and usually does not need to be part of the

[sqlalchemy] Problems reflecting "dbo" schema dynamically (ORM) in MS SQL Server

2019-11-27 Thread Felipe Araya Olea
Hello, I am having problems reflecting my tables from the MS SQL Server database that have the schema "dbo". I have tried using the following code. engine = db.create_engine("mssql+pyodbc:///?odbc_connect=%s" % params) # Engine works, because I have tested it using CORE meta =

Re: [sqlalchemy] Accessing rowid when adding or merging in Oracle

2019-11-27 Thread Mike Bayer
On Wed, Nov 27, 2019, at 1:05 PM, Javier Collado Jiménez wrote: > One more thing about returning data. When I insert rows one by one, it works: > for datum in data: > statement=table.insert().values(**datum).returning(table.c.rowid) > inserted_rowids=conn.execute(statement) >

Re: [sqlalchemy] Accessing rowid when adding or merging in Oracle

2019-11-27 Thread Javier Collado Jiménez
One more thing about returning data. When I insert rows one by one, it works: for datum in data: statement=table.insert().values(**datum).returning(table.c.rowid) inserted_rowids=conn.execute(statement)