Skip to content

How to get value from sqlalchemy .execute() method? Python + Sqlalchemy+ MS SQL server #5434

@edo101

Description

@edo101

Hi wrote a method to get the status of a csv file in a sql server table. The table has column named CSV_STATUS, and for the particular csv, I'd like my method to give me the value of the CSV status. I wrote the following function:

def return_csv_status_db(db_instance, name_of_db_instance_tabledict, csvfile_path):
    table_dict = db_instance[name_of_db_instance_tabledict]
    csvfile_name = csvfile_path.name
    sql = db.select([table_dict['table'].c.CSV_STATUS]).where(table_dict['table'].c.CSV_FILENAME == csvfile_name)
    result = table_dict['engine'].execute(sql)
    print(result)

Whenever I print result, it returns: <sqlalchemy.engine.result.ResultProxy object at 0x0000005E642256C8> How can I extract the value of the select statement?

Versions

  • OS: Windows Server 2012
  • Python: 3.6
  • SQLAlchemy: Not sure. Latest one?
  • Database: SQL Server 2017
  • DBAPI: Not sure, default?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionissue where a "fix" on the SQLAlchemy side is unlikely, hence more of a usage question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions