airtoxin / pysqldf Goto Github PK
View Code? Open in Web Editor NEWThis project forked from yhat/pandasql
sqldf for pandas DataFrame
License: MIT License
This project forked from yhat/pandasql
sqldf for pandas DataFrame
License: MIT License
Hi - I'd consider working on this as an enhancement : but would appreciate some insight/ advice on it. It is my belief there were some PR for that on the original yhat repo but I can not find it now.
lmk. stephen boesch
Hi,
When I try to use at Jupyter Notebook , I got below error.
Could you give me some hint?
from pysqldf import SQLDF, load_meat, load_births
meat = load_meat()
births = load_births()
sqldf = SQLDF(globals())
sqldf.execute('select * from meat limit 10').head()
OperationalError Traceback (most recent call last)
in ()
1 sqldf = SQLDF(globals())
----> 2 sqldf.execute('select * from meat limit 10').head()
C:\Miniconda2\envs\py27\lib\site-packages\pysqldf\sqldf.pyc in execute(self, query)
74 result = None
75 finally:
---> 76 self._del_table(tables)
77 return result
78
C:\Miniconda2\envs\py27\lib\site-packages\pysqldf\sqldf.pyc in _del_table(self, tablenames)
115 def _del_table(self, tablenames):
116 for tablename in tablenames:
--> 117 self.conn.execute("drop table " + tablename)
118 self.conn.commit()
119
OperationalError: no such table: meat
hi, i think pysqldf is more powerful library than pandasql.
According to the author's example:
from pysqldf import SQLDF, load_meat, load_births
sqldf = SQLDF(globals())
meat = load_meat()
births = load_births()
print sqldf.execute("SELECT * FROM meat LIMIT 10;").head()
i find the hint that sqlite3.OperationalError: no such table: meat
who can help me?
pandas 1.2.4 python 3
I'm using pandas 0.23.3 and pysqldf is not compatible - the flavor argument for to_sql has been removed, so the call fails.
I've edited the code in _write_table of pysqldf/sqldf.py to read
to_sql(df, name=tablename, con=self.conn, dtype=dtype)
instead of
to_sql(df, name=tablename, con=self.conn, flavor="sqlite", dtype=dtype)
which corrects the problem for this version of pandas. I guess a try/except would fix it generically?
don't change column dtype
# in _ensure_data_frame
for col in df:
if df[col].dtype==np.int64:
df[col] = df[col].astype(np.float)
elif isinstance(df[col].get(0), pd.tslib.Timestamp):
df[col] = df[col].apply(lambda x: str(x))
The setup.py
refers to the nonexisting file.
The yhat/pandasql has limited maintainers attention so I am looking for offshoots/forks that might be more active. Am I in the right place?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.