Python and _rdb pacakge

Post Reply

Topic author
tdirven
Member
Posts: 8
Joined: Wed Apr 01, 2020 9:11 am
Reputation: 0
Status: Offline

Python and _rdb pacakge

Post by tdirven » Wed Sep 20, 2023 10:35 am

Hello,

I am using python 3.10 on I64 with the Rdb package.
What i don't understand is why python cannot create temp files that are needed for Rdb.

Example:
Python program has to delete 10 records from a Rdb table that works fine.
Same program has to delete 10.00 records it always fails with this error.
What should I do to get this solved.

%RDB-F-SYS_REQUEST, error from system services requestd
-COSI-F-CREATERR, cannot create file


Code: Select all

Short Python code:

import requests
import time
import json
import re

import _rdb
import _decc

    sqlca = _rdb.sqlca()
    if sqlca.attach(source_database) != 0:
        raise Exception("attach failed:\n" + sqlca.message)

    print(time.strftime('%Y-%m-%d %H:%M:%S') + ": starting cleanup")
    threshold_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time() - expire_time))
    print(f"threshold_time: {threshold_time}")
    sqlca.set_readwrite()
    query_str = f'''DELETE FROM DATA_TO_CLOUD
                    WHERE PROCESSING_STATUS = 'PROCESSED'
                    AND CREATED_AT < TIMESTAMP '{threshold_time}' '''

    cleanup_query = sqlca.prepare(query_str)
    if DEBUG:
        print(query_str)
    if cleanup_query == None:
        raise Exception("cleanup failed:\n" + sqlca.message)
    if cleanup_query.exec() == 0:
        print("delete: ", sqlca.code, sqlca.message)
        sqlca.commit()

    else:
        print("delete failed: ", sqlca.code, sqlca.message)
        sqlca.rollback()

%RDB-F-SYS_REQUEST, error from system services requestd
-COSI-F-CREATERR, cannot create file
Last edited by tdirven on Wed Sep 20, 2023 10:37 am, edited 2 times in total.

User avatar

cct
Master
Posts: 127
Joined: Sat Aug 15, 2020 9:00 am
Reputation: 0
Location: Cambridge, UK
Status: Offline

Re: Python and _rdb pacakge

Post by cct » Wed Sep 20, 2023 12:48 pm

From the error I would suggest that RDB cannot create the file. Is this an established working RDB setup?

Chris
--
Chris


Topic author
tdirven
Member
Posts: 8
Joined: Wed Apr 01, 2020 9:11 am
Reputation: 0
Status: Offline

Re: Python and _rdb pacakge

Post by tdirven » Wed Sep 20, 2023 1:54 pm

Hello,

Yes this a working Rdb setup.
When I use the same user and go into intercative SQL
I can delete the records without any problem.
It looks like python is overriding some settings.
I know it will execute everything in UTF8 mode.
Perhaps Rdb can’t create UTF8 “compatible” files.

//Toine


Topic author
tdirven
Member
Posts: 8
Joined: Wed Apr 01, 2020 9:11 am
Reputation: 0
Status: Offline

Re: Python and _rdb pacakge

Post by tdirven » Thu Sep 21, 2023 3:03 am

I have added these logical names (sys$login and sys$scratch) when I start the python application in a detached process since Rdb needs these so it knows on which disk to create the tempory files. I think it is working fine now.

$ sys$login
$ sys$scratch

//Toine


sodjan
Active Contributor
Posts: 40
Joined: Mon Apr 24, 2023 3:51 am
Reputation: 0
Status: Offline

Re: Python and _rdb pacakge

Post by sodjan » Thu Sep 21, 2023 4:28 am

I think I can confirm that what you describe in your last post is the real issue.
We had the same issue with an detached process where Rdb needed a temp file.
Defining SYS$SCRATCH (system wide, in our case) solved that.
(SYS$LOGIN should not be needed, if I'm not wrong.)

And this has nothing to do with Python as such.
In our case it was a "normal" EXE written in Cobol.

And also, just to be clear, it has nothing to do with UTF-8 either... :-)

Post Reply