I use python and sqlalchemy but pd.read_ sql_ query is so slow so I try to write the data in csv file in my procedure with unload statment to cleint then i want to use pd.read_scv

UNLOAD TABLE #table INTO CLIENT FILE 'c:\tmp\test_data.csv;

i get error messages

'Client application does not allow data to be written to this file '

in pyhon code from sqlalchemy

Thanks for the help in advance

asked 26 Nov, 08:23

salwa's gravatar image

salwa
2513
accept rate: 0%

When Python does not support to allow the required callback, is there a chance you could use a DBISQL client instead? DBISQL will ask the client to allow client-side read/write operations...

(02 Dec, 04:48) Volker Barth

Try this: http://dcx.sap.com/index.html#sqla170/en/html/812c36fb6ce21014a20ae7873e5607d0.html

There are times when a callback is required though (such as when the UNLOAD is in a stored procedure) and you won't be able to do that from python, I don't think. See DB_CALLBACK_VALIDATE_FILE_TRANSFER at http://dcx.sap.com/index.html#sqla170/en/html/3bd12e6c6c5f1014b9d2d85be55df0a4.html

permanent link

answered 26 Nov, 08:50

John%20Smirnios's gravatar image

John Smirnios
10.0k385129
accept rate: 38%

Thanks, there is any possibility in my procedure to give the authority (DB_CALLBACK_VALIDATE_FILE_TRANSFER ) in my procedure I wrote: SET OPTION allow_write_client_file = 'On';

(27 Nov, 05:11) salwa
Replies hidden

You probably want 'SET TEMPORARY OPTION'... since SET OPTION is actually an operation that gets logged.

Setting the option is different from providing a validation callback. The callback is code provided at the client that allows the application to permit or reject client file transfers.

(27 Nov, 05:14) John Smirnios

thanks, I also tried 'SET Temporary OPTION allow_write_client_file =' On ';' the message from interactive sql is: "has a procedure or trigger calls to write in file allow this transfer refuse this exaggeration " and in paython code The client application does not allow the transmission of data initiated by the server. To allow the transmission of data initiated by the server, the application must register a validation callback mechanism in the client library.

(02 Dec, 05:07) salwa
Replies hidden

The point is you need to register the callback (which seems not to be possible with SQL Anywhere's Python support) when the client read is initiated by the server, see the doc topic cited by John:

For data security, the server tracks the origin of statements requesting a file transfer. The server determines if the statement was received directly from the client application. When initiating the transfer of data from the client, the server sends the information about the origin of the statement to the client software. On its part, the Embedded SQL client library allows unconditional transfer of data only if the data transfer is being requested due to the execution of a statement sent directly by the client application. Otherwise, the application must have registered the validation callback described above, in the absence of which the transfer is denied and the statement fails with an error. If the client statement invokes a stored procedure already existing in the database, then the execution of the stored procedure itself is considered not to have been for a client initiated statement. However, if the client application explicitly creates a temporary stored procedure then the execution of the stored procedure results in the server treating the procedure as having been client initiated. Similarly, if the client application executes a batch statement, then the execution of the batch statement is considered as being done directly by the client application.

In other words: A simple UNLOAD statement (like the sample shown in your question) issued by the client should not require a registered callback and as such should work from Python. At least that's my understanding.

(02 Dec, 06:55) Volker Barth
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×23

question asked: 26 Nov, 08:23

question was seen: 74 times

last updated: 02 Dec, 06:57