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

SQLAlchemy support? #17

Closed
mario opened this issue Feb 25, 2013 · 45 comments
Closed

SQLAlchemy support? #17

mario opened this issue Feb 25, 2013 · 45 comments

Comments

@mario
Copy link

mario commented Feb 25, 2013

Hello,

I was just wondering if you've got any idea when PostgreSQL is going to be supported?

Appreciate the work you're doing!

Cheers!

@nicolaiarocci
Copy link
Member

Hello!

I'd love to add PostgreSQL support but it's not something I would feel confident doing right now as I don't work with that DB (not in Python at least). PostgreSQL support would be a fantastic opportunity for other contributors to jump in! There's a DataLayer interface in place already, ready to be abused. If somebody wants to help well, let's get in touch!

@mario
Copy link
Author

mario commented Feb 26, 2013

I assume we can use flask-SqlAlchemy to kill several flies with one kill?

@mario
Copy link
Author

mario commented Feb 26, 2013

Do you frequent any irc channels, skype, gtalk or something? So we can talk what would be involved in this.

@inactivist
Copy link

I'm interested, if only to help test. Not sure what I can do on the dev side.

@mario
Copy link
Author

mario commented Feb 26, 2013

Here's a bounty - anyone that implements this properly gets a small VM at 6sync for three months! And you get to contribute to open source!

@nicolaiarocci
Copy link
Member

I guess Flask-SqlAlchemy would work, although I'm not sure a full featured ORM is needed. Again, I'm out of my comfort zone here so I'm open to discussion, ideas and pull requests.

I've been amusing myself with the idea of an irc channel for Eve, but it seemed a bit overkill at this stage. Also, by keeping the discussion here we allow everybody interested to easily jump in with his/her opinions and ideas.

@mario
Copy link
Author

mario commented Feb 26, 2013

I'm all for irc channel, let's go!

@LarryEitel
Copy link

I too am very interested in collaborating with anyone working with/on
Nicola's awesome API!!! :) Skype Group is excellent or perhaps Google
Hangout. IRC is great too especially if dev's are aware of it's existence.
Perhaps the Flask IRC channel is good place to hang.

On Tue, Feb 26, 2013 at 10:19 AM, Mario Đanić notifications@github.comwrote:

I'm all for irc channel, let's go!


Reply to this email directly or view it on GitHubhttps://github.com/nicolaiarocci/eve/issues/17#issuecomment-14123448
.

@nicolaiarocci
Copy link
Member

@inactivist hey man I'm sure you can lend a hand in one way or another!

@mario
Copy link
Author

mario commented Feb 26, 2013

IRC channel is now on freenode #evehq :)

@nicolaiarocci
Copy link
Member

the cat is out of the bag I guess

@inactivist
Copy link

Is it reasonable for SQL support to exclude dict and list (nested) schema data types?

@mario
Copy link
Author

mario commented Mar 8, 2013

I think supporting whatever sqlalchemy supports is fine :)

On Friday, March 8, 2013, Michael Curry wrote:

Is it reasonable for SQL support to exclude dict and list schema data
types?


Reply to this email directly or view it on GitHubhttps://github.com/nicolaiarocci/eve/issues/17#issuecomment-14626354
.

@nicolaiarocci
Copy link
Member

@inactivist I guess we could get away with that, at least on initial release. Remember you can have your own custom data validator within the SQL subpackage (for reference, see the validator for the mongo subpackage).

@Tefnet
Copy link
Contributor

Tefnet commented Apr 16, 2013

If someone would like to test/review - here is my initial implementation:
Tefnet@963769f

@kpanic
Copy link

kpanic commented Apr 16, 2013

@Tefnet If someone else will not pickup your branch, I would like to try it and add tests to it this weekend!

@nicolaiarocci
Copy link
Member

@Tefnet at quick glance it looks like a great start! I'll review it later, thank you!
@kpanic please join in!

@nicolaiarocci
Copy link
Member

A quick note (haven't looked at the code yet). It seems kind of awkward that one has to define the schema twice, one for SQLAlchemy and another in settings.py.

@mario
Copy link
Author

mario commented Apr 17, 2013

I don't find that particularly strange due to the way Eve works - however, one could write a script to translate the SQLAlchemy models and spit out Cerberus validation rules for settings.py.

@Tefnet
Copy link
Contributor

Tefnet commented Apr 17, 2013

I've made simple decorator for SQLAlchemy model Tefnet@bfb3798
but there are a couple of problems:

  1. Sometimes it is hard to map SQLAlchemy property to eve schema (for example composite column property)
  2. Right now I don't know how it could be registered in app. The problem is that I think I need app.driver to setup models, but I get it from app instance when config/schema is already parsed.

@nicolaiarocci
Copy link
Member

I wouldn't worry much about the double definition, not now at least. Agree with @mario however, a script would be a nice tool. @Tefnet I added some comments to your repo. Very encouraging, thank you!

@Tefnet
Copy link
Contributor

Tefnet commented Apr 21, 2013

@kpanic
Copy link

kpanic commented Apr 21, 2013

A WIP based on #45 related to SQLAlchemy tests:

branch: https://github.com/kpanic/eve/commits/sqlalchemy (might need a rebase from #45 )
settings: https://gist.github.com/kpanic/5431065

@mario
Copy link
Author

mario commented May 22, 2013

Guys, let's push this properly - I have time this week, so let's meet up on IRC and at least finish something worthy of a release? :)

@mario
Copy link
Author

mario commented Jun 7, 2013

Guys, you alive? :)

@nZac
Copy link

nZac commented Jul 15, 2013

Ping.

Has this gone anywhere? I would be interested in helping where I can. We might be able to use something like this at work so I could devote some time to getting SQLAlchemy up and running.

@mario
Copy link
Author

mario commented Jul 15, 2013

Hi,

are you on irc @nZac? Let's talk!

Cheers.

@nZac
Copy link

nZac commented Jul 15, 2013

#python-eve right?

@mario
Copy link
Author

mario commented Jul 15, 2013

Yup.

On Mon, Jul 15, 2013 at 5:17 PM, Nick Zaccardi notifications@github.comwrote:

#python-eve right?


Reply to this email directly or view it on GitHubhttps://github.com/nicolaiarocci/eve/issues/17#issuecomment-20976637
.

@mario
Copy link
Author

mario commented Aug 7, 2013

@nZac nZac around? :)

@alanhamlett
Copy link

This gist might help:
https://gist.github.com/alanhamlett/6604662
Model.to_dict turns a Model (and it's relationships) into a Python dict ready for serializing
Model.set_columns takes a dict and updates a Model (and it's relationships)

@reissmann
Copy link

What's the current status on this? Is only testing needed or is essential implementation work still missing?

@nicolaiarocci
Copy link
Member

there's a guy on the mailing list who's willing to work on the branch and is looking for help. Another guy jumped in (via email).

I'm still interested in merging as soon as it is mature enough so everybody is welcome to chime in (maybe by answering to that message on the ML in the first place).

@amleczko
Copy link
Member

amleczko commented Apr 3, 2014

I have also started to work on my fork - https://github.com/RedTurtle/eve/tree/sqlalchemy based on @Tefnet branch.

@nicolaiarocci
Copy link
Member

@amleczko this is very interesting, consider getting in touch with the guys on the mailing list so maybe you can join efforts.

@nicolaiarocci
Copy link
Member

Hello everybody, I just merged a huge PR to the SQLAlchemy branch. It brings the functionality almost on par (with some tests and refactoring) with current Eve 0.4-dev so you may all want to work on it.

Author's comment on the PR (#311)

I moved forward the SQLAlchemy branch to support all the changes happened to Eve since last commit to the branch, or at least the ones affecting the find methods of the data layer. The current state of the SQLAlchemy support is a bit of a regression since I haven't updated the previous implementations of the find_one and insert methods in the data layer to comply with Eve 0.4. Mostly though I kicked off some tests for SQL DBs by porting them from the get method tests of Mongo. Hopefully this means we can make progress on the branch a little faster.

For reference:

@nicolaiarocci
Copy link
Member

All those interested, #321 (support for DELETE and lots of tests) was just merged to the SQLAlchemy branch.

Things are moving forward rather quickly now and I'd really appreciate if someone would code-review and/or contribute to the sql branch.

@amleczko
Copy link
Member

  1. What is the best way/place to review the code?
  2. I have several questions regarding schema registration that are not code-review related but more general principles sqlalchemy branch is following; where should I ask/discuss them?

@nicolaiarocci
Copy link
Member

@amleczko I invited the main sql contributor to join the mailing list. Also, #326 has just been merged to the sql branch.

@nicolaiarocci nicolaiarocci reopened this Apr 28, 2014
@nicolaiarocci nicolaiarocci added this to the 0.5 milestone Apr 28, 2014
@dedalusj
Copy link

I'm the contributor to the merges to the SQL branch of Eve. I just applied to join the mailing list so we should be able to discuss this there soon.

Meanwhile...in the past few weeks I focused on getting to near feature parity with eve 0.4-dev and more importantly in porting the relevant integration tests to SQL.

I'm sure there is plenty of room for improvement in my implementation, especially for supporting features that are particular to SQL like composite primary keys. Here is a list of things I have planned for the immediate future or where people could focus:

  • The most important thing at the moment would be to review the tests. They all pass but it would be nice to have someone go over them to make sure I haven't fooled myself here and there.
  • There is A LOT of repeated code between the tests for Mongo and the tests for SQL. It would be nice to make them DRY so that new tests can be added easily to both extensions.
  • General review of the extension code to see if anything can be simplified or improved. I moved pretty quickly in the past few weeks and I may have overlooked a better implementation.

@petrjasek
Copy link
Member

There is A LOT of repeated code between the tests for Mongo and the tests for SQL. It would be nice to make them DRY so that new tests can be added easily to both extensions.

👍 that would be also useful for elastic extension

@jofell
Copy link

jofell commented May 7, 2014

Hi. We are trying out the SQLAlchemy branch, and we're wondering if the filters feature are already integrated. If it is, we would like to know how they are invoked on the API (like how does the where query work?)

If in case it's not yet here, we would love to help out to contribute code, and also we would like to know if you guys have any preference as to how the where query should look like.

Cheers!

@dedalusj
Copy link

dedalusj commented May 8, 2014

Yes they are although only in the python form. I made no effort to support the Mongo query syntax.
This is an example request of a where filter in action:

http://127.0.0.1:5000/people/?where=firstname==George

where obviously firstname is a column of the people table/resource. Since I'm supporting the Python syntax any valid combination of conditionals and logical operators should work. Please let me know if you find any issues

@nicolaiarocci
Copy link
Member

Status update: Python 3.4 compatibility has just been added with PR #382. Cheers!

@nicolaiarocci
Copy link
Member

Also see PR #424 which I find very interesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests