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

2019-11-28 Thread Felipe Araya Olea
UPDATE! I have gone to the mssql server, manually added a new primary key to the table I was looking for. I used the following SQL code if anyone is interested: ALTER TABLE AssetCashFlows ADD ID INT IDENTITY; ## Then I had to do a second query, to transform ID into a primary key. ALTER

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

2019-11-28 Thread Felipe Araya Olea
Hello Mike, Thanks for your answer. I think I am definitely closer to find the solution thanks to your comments, I created a new table in mssql without using any pre-existing schema and also making sure it has a primary key. I managed to find that table using the code I showed you above and

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 =