Code Monkey home page Code Monkey logo

pysqldf's Issues

Support for a different sql backend (e.g. mysql)

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

how to use at jupyter notebook

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

sqlite3.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

Compatibility with pandas 0.23.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?

dtype

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))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.