0
 import pandas as pd
 data_BG2= pd.read_sql("SELECT * FROM [dbo].[Bullgear geometry] WHERE [Bullgear]=?", "3810907-01110", cnxn)

where cnxn is the connection

This is the first time I am using Panda and I keep getting the following error

ArgumentError: Could not parse rfc1738 URL from string '3810907-01110'

This error is only there if a searching for a string in the database. if I search for a float or an integer it works.

If I run it via a cursor like below the exact same code works.

cursor=cnxn.cursor()
cursor.execute("SELECT * FROM [dbo].[Bullgear geometry] WHERE [Bullgear]=?","3810907-01110")

for i in cursor:
    print (i)
Dale K
  • 25,246
  • 15
  • 42
  • 71
  • You just asked this exact same question then deleted it. Why? – Dale K Jan 10 '23 at 03:38
  • 1
    Check the documentation. The substitution parameters are NOT the second paramater to `read_sql`. You need `pd.read_sql("SELECT...", cnxn, params=("3810907-01110",))`. – Tim Roberts Jan 10 '23 at 03:42
  • Have you tried reading the [pandas.read_sql()](https://pandas.pydata.org/docs/reference/api/pandas.read_sql.html) documentation yet? – AlwaysLearning Jan 10 '23 at 06:07
  • Thanks Tim, that did the trick. i reread the documentation and i totally ignored the params argument the first time around. Thankyou – Dhruv Kumar Jan 10 '23 at 12:33

0 Answers0