#Sql problems in python

27 messages · Page 1 of 1 (latest)

crimson ruin
#

Can you end your query with a ;?

gusty condor
#

after?

#

i tried and no work

crimson ruin
#

change it to globals()

#

instead of locals()

gusty condor
#

nope 😦

#

still getting an Attribute erroe

#

erroe

crimson ruin
#

can you share?

#

oh wait

#

i see

#

hmm

gusty condor
#

something to do with str

#

i think its because in my spreedsheet id is an int

crimson ruin
#

can you share the code you have exactly?

#

oh hm

gusty condor
#
import pandas as pd
import pandasql as ps 

sheet_id = "1ElftZLF_sJBl6UNldK9uLIIlQwxqAhHj1MyaD1A7Pt0"

df = pd.read_csv(f"https://docs.google.com/spreadsheets/d/{sheet_id}/export?format=csv")
df = df.set_index("id")

sql_query = "SELECT * FROM df WHERE age < 15"
print(ps.sqldf(sql_query, globals()))
#

how can i make my id field strings?

#

this is so confusing

#

i dont get whats wrong

crimson ruin
gusty condor
#

ill try look

echo ravine
#

PandaSQL hasn't been updated in 7 years. Checking the GitHub there are 50 issues, in the last 3 months people have begun reporting that the package no longer works.

Do not use pandasql, it will only continue to break and will remain unsupported.

If you insist on using it, use pip to uninstall sqlalchemy and reinstall the 1.4 version with this command

pip install SQLAlchemy==1.4.46

It breaking coincides with the release of SQLAlchemy 2.0, so I'm guessing going back to 1.4 will fix it.

gusty condor
echo ravine
#

I don't use pandas so have no idea what's available.