records
records copied to clipboard
API improvements
Hello Kenneth,
First of all, please allow me to compliment you on your great work on records as well as all other for Humans projects.
I write this email because I've made a few additions/customizations to records for personal use, and I feel like perhaps I should "give it back" by sharing these improvements with you and the community.
I would summarize the changes in:
- use records as the underlying supporting library, and on top of it, add an API that matches ezsql/wpdb (https://make.wordpress.org/core/tag/wpdb/) to make it even easier to perform a few common tasks like:
- Getting timing on last query
- Getting number of affected rows by most recent query
- Getting last insert id
- Get a single row/column by offset
- Get a single value
- Log queries
- Automatically replace %f, %d by %s since Python's DB API spec doesn't support those parameter formats, but people are usually unaware of it Insert, updates and deletes like
db.insert('test_user', username='scott', password='tiger', created_at=datetime.datetime.now())
db.insert('test_user', {'username': 'JONES', 'password': 'STEEL'})
db.update('test_user', {'password': 'shepard'}, {'username': 'scott'})
db.delete('test_user', {'username': None}) # None is converted to NULL
db.delete('test_user', username=None)
- The other significant change is that I've removed the dependency on sqlalchemy, and instead just use the native drivers (psycopg2, pymysql), but still allowing the user to connect using a DSN url. The code can be found on https://github.com/dareenzo/ezrecords
I haven't made a PR because first I'd like to get your consideration on the proposed changes. Since I already have the code functioning, porting should be straightforward once you've replied on whether you'd like to have these features on records too.
@dareenzo the feature list seems really impressive.
On the other hand, the differences with records seems to be rather big, at least in following areas:
recordsprefers simplicity and supporting the most requested features.ezrecordssupports many more features.recordsrelies onsqlalchemywhile you try to avoid it.
Personally I feel, both "drinks" (records and ezrecords) are of excellent taste, but mixing them could result in a bit strange side effects.
For that reason I propose to close this issue, thank you for the offer and do "cherry-picking" at the moment, someone asks for specific feature from your menu.
@kennethreitz what do you think?