Sitelet https://web.archive.org/web/20201123005632/https://github.com/oracle/python-cx_Oracle/issues/476
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem running SQL query having regexp using python #476

Open
Shailesh-Pradhan opened this issue Sep 5, 2020 · 2 comments
Open

Problem running SQL query having regexp using python #476

Shailesh-Pradhan opened this issue Sep 5, 2020 · 2 comments
Labels

Comments

@Shailesh-Pradhan
Copy link

@Shailesh-Pradhan Shailesh-Pradhan commented Sep 5, 2020 •

Hello
Firstly i'm an entry level coder in python.
So basically i'm trying to query the oracle sql developer via python. I'm able to set up connections successfully with database.
Normal SQL query works totally fine. For e.g : select * from table_name
However, i have an SQL query that contains some special characters. Below is the code

NAM_100 = """SELECT DISTINCT 'NAM100: Text Field Basename should only have legal characters' val_desc, pa.ISO_COUNTRY_CODE,
p.poi_id, p.cat_id, trim(n.name) poi_basename, n.name_id, 'Basename' attr_name, n.name attr, n.language_code, pl.link_id
FROM poi p
JOIN poi_names pn ON p.poi_id = pn.poi_id
JOIN poi_name n ON n.name_id = pn.name_id
JOIN poi_address pa ON pa.poi_id = p.poi_id
JOIN poi_location pl ON pl.location_id = pa.location_id
WHERE REGEXP_LIKE (n.name,'[°´–ªº¿•³Ÿ;®·¶«»^?]') ORDER BY 2,1 """

print("Running Query")                   
nam100 = NAM_100.encode('utf-8')
df = pd.read_sql(nam100,con=conn)
df.to_csv('nam_100.csv',index=False)

When i tried running it, the output results very less counts as compared to the counts that i get when i run the query directly over the oracle sql developer. It looks like some characters are ignored.
For e.g
O/p running sql via python : 50 rows
O/p running sql over oracle sql developer: 500 rows

Can someone help me this ?

@cjbj
Copy link
Member

@cjbj cjbj commented Sep 6, 2020

When you open an issue, use the green 'new issue' button https://github.com/oracle/python-cx_Oracle/issues/new/choose which will ask you to share useful information such as your cx_Oracle version. E.g. https://raw.githubusercontent.com/oracle/python-cx_Oracle/master/.github/ISSUE_TEMPLATE/general-questions-and-runtime-problems.md

What cx_Oracle version do you have? What character set are you using, see https://cx-oracle.readthedocs.io/en/latest/user_guide/globalization.html ? Give us a runnable Python script that also creates the table and inserts data.

@stale
Copy link

@stale stale bot commented Nov 19, 2020

This issue has been automatically marked as inactive because it has not been updated recently. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.