[Tutor] SQL Server Script

dn PythonList at DancesWithMice.info
Mon Apr 17 20:36:51 EDT 2023


On 18/04/2023 04.18, Dylan Armstrong via Tutor wrote:
> Hello,
> I'm trying to create a python script that exports the results of a query from sql into an excel file. I got the original version of the code to work but I want to add python variables into my sql code because of the weird variable format differences between oracle and sql variables. I heard that you can insert python variables into the code by placing a ":" before the variable, declaring the variable after the sql query is defined, and having a curser execute the query with the variables as parameters but I'm not sure how to do that last step. I'm also not sure how to give a specific file path destination for my newly created excel file. I'm using oracledb and pandas. my python version is 3.10.11. Sensitive information has been replaced by generic variables.

NB suspect some info missing from OP. Please copy-paste because 
attachments don't come-through. Will be happy to help, later...

(with apologies for a necessarily brief response)

A tutorial: 
https://www.oracle.com/database/technologies/appdev/python/quickstartpythononprem.html
(and other references available on same web-site)

Docs for the Python-Oracle "Connector": 
https://python-oracledb.readthedocs.io/en/latest/

Third party alternative (maybe): 
https://www.oracletutorial.com/python-oracle/connecting-to-oracle-database-in-python/


-- 
Regards,
=dn


More information about the Tutor mailing list