Category : stored-procedures

I have SP which has input as well as output parameter, I am figuring out how can I bind output parameter def call_sp(self, input_data): with self.engine.begin() as conn: stmt = text("""EXEC databasename.my_sp @id = :id , @fname = :fname, @returnData OUTPUT""") stmt.bindparams(bindparam("id", type_=int)) stmt.bindparams(bindparam("fname", type_=String)) result = conn.execute(stmt, { ‘id’: input_data.id, ‘fname’: input_data.fname}) myClassObj = ..

Read more

After I inform a bigger value for a variable my Pyton/Flask/Postgres/StoraredProcedure program stop of working. I’m using "TRY:/Except:" but I don’t know if I’m using in the right way. In this example CPF allow only 11 characters but when it receive 12 characters this broke the application. from flask import Flask, request, render_template app = ..

Read more

I’m trying to understand what is wrong with this code: from flask import Flask from flask_sqlalchemy import SQLAlchemy con_str = ‘postgresql://user:[email protected]_PostgresDB:5432/base’ app = Flask(__name__) #Acesso a base app.config["SQLALCHEMY_DATABASE_URI"] = con_str db = SQLAlchemy(app) conn = db.engine.raw_connection() results = conn.cursor().callproc("usp_pes_pessoa",[1]) #… My reference was: [1]https://docs.sqlalchemy.org/en/14/core/connections.html#calling-stored-procedures The code not call the procedured! Thanks for your time! Source: ..

Read more

I have a stored procedure as below. procedure download_data( id in number, test_ids in test_num_array := test_num_array(), data_instance out sys_refcursor, titles out test_two_dim_array ) —- ——— I am writing a python program which as below connection = Util.getConnection() cursor=connection.cursor() cur_var=cursor.var(cx_Oracle.CURSOR) id = cursor.var(cx_Oracle.NUMBER, 123456) test_ids = cursor.arrayvar(cx_Oracle.NUMBER, [123456, 7890]) titles = [[]] cursor.callproc("fast_rprt_dwnld.download_analysis_data_fs2", [id, test_ids,cur_var,titles]) ..

Read more

I am trying to pass a file directory to a Python script in order to process the contents. Here is the EXEC statement and below my code is the error. It is supposed open the file and do some processing. EXEC ScrapeData ‘F:FinancialResearchSECmyEdgarsec-edgar-filingsWIRE-Q{$content}01753926-20-000110full-submission.txt’ DROP PROCEDURE IF EXISTS ScrapeData; GO CREATE PROCEDURE [dbo].[ScrapeData] (@filepath varchar(300)) AS ..

Read more

Working with the SEC Edgar Lofgile database I face a couple of challenges. (https://www.sec.gov/dera/data/edgar-log-file-data-set.html) My job is to download the data step by step and then assign the various IP addresses to the companies. Using a combination of WRDS, the ARIN Bulk Whois database, and string matching, I was able to match companies to IP ..

Read more

Here’s the stored procedure: PROCEDURE [dbo].[procIncrementInt] ( @IN_INT int, @OUT_INT int OUTPUT ) AS BEGIN SET NOCOUNT ON SET @OUT_INT = @IN_INT + 1 END And here’s the Python code that doesn’t work: import pyodbc odbcConn = pyodbc.connect(‘DRIVER={ODBC Driver 17 for SQL Server};SERVER=HHPCSQLEXPRESS;DATABASE=hhDb;Trusted_Connection=yes’) odbcCursor = odbcConn.cursor() execProcSql = """EXEC procIncrementInt @IN_INT=?, @OUT_INT=?""" inInt = 7 ..

Read more

I’m following the FastAPI docs and I’m having a hard time figuring out how can I call a oracle stored procedure. This is the code I have so far: main.py from fastapi import FastAPI, Depends from sqlalchemy.orm import Session from ansimarkup import ansiprint as print import cx_Oracle import os from api.utils.dependencies import get_db import api.core.database ..

Read more