Django模型/ SQLAlchemy膨胀!任何真正的Pythonic DB模型吗? [英] Django Models / SQLAlchemy are bloated! Any truly Pythonic DB models out there?

查看:150
本文介绍了Django模型/ SQLAlchemy膨胀!任何真正的Pythonic DB模型吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们可以找到解决方案/ s修复Python数据库世界?



更新:一个'lustdb'原型是由Alex Martelli编写的 - 如果你知道任何轻量级的高级数据库库有多个后端,我们可以包装语法糖蜂蜜,请称重! strong>

  from someAmazingDB import * 
#we导入智能模型类和db对象, s
class Task(model):
title =''
done = False #native类型不是我们必须考虑的自定义对象!

db.taskList = []
#or
db.taskList = expandingTypeCollection(任务)#不确定这个语法是什么

db [ 'taskList']。append(Task(title ='Beat old sql interfaces',done = False))
db.taskList.append(任务(说明不同的语法模式,只是使用kwargs

#这里它应该被自动保存到默认的数据库选项

#by默认情况下我们应该能够重新加载控制台并访问默认的db:

>>来自someAmazingDB import *
>> print'Done tasks:'
>>对于db.taskList中的任务:
>> if task.done:
>> print task.title
'演示不同的语法模式'

em> Python ,webPy和Cherry Py以及 KISS



自动 Python到SQL 类型翻译或NoSQL。
我们不必完全是SQL兼容!只是一个可扩展的子集或忽略它!



Re:模型更改,当开发者尝试更改它或有一组明智的默认值时, p>

这里是挑战: 上述代码应该只需要很少的修改或思考。



2010年,我们应该能够在我们的睡眠中对可扩展的简单数据库进行编码。



如果您认为这很重要,请upvote!

解决方案

我一直很忙,在这里,它是根据LGPL发布:
http://github.com / lukestanley / lustdb



它使用JSON作为后端。



不是相同的代码库 Alex Martelli
我想让代码更可读和可重用的不同的
后端等。



其他我一直在面向对象的HTML元素工作
以类似的方式在Python中可访问,还有一个用于使web.py
更简单的库。



我在想方法使用所有3元素与自动
MVC原型构造或智能映射。



虽然旧的基于文本的模板Web编程将在
左右,但仍然是因为的遗留系统,并且因为它不
需要任何特定的库或实现,我很快我们会
有一个更有效的方式建立鲁棒,原型友好的
网络应用程序。 / p>

请参阅邮寄名单那些感兴趣的人。


"Make things as simple as possible, but no simpler."

Can we find the solution/s that fix the Python database world?

Update: A 'lustdb' prototype has been written by Alex Martelli - if you know any somewhat lightweight, high-level database libraries with multiple backends we could wrap in syntax sugar honey, please weigh in!

from someAmazingDB import *  
#we imported a smart model class and db object which talk to database adapter/s
class Task (model): 
    title = ''
    done = False #native types not a custom object we have to think about!

db.taskList = []
#or
db.taskList = expandableTypeCollection(Task) #not sure what this syntax would be

db['taskList'].append(Task(title='Beat old sql interfaces',done=False))
db.taskList.append(Task('Illustrate different syntax modes',True)) # ok maybe we should just use kwargs

#at this point it should be autosaved to a default db option

#by default we should be able to reload the console and access the default db:

>> from someAmazingDB import *
>> print 'Done tasks:'
>> for task in db.taskList:
>>     if task.done:
>>         print task.title
'Illustrate different syntax modes'

I'm a fan of Python, webPy and Cherry Py, and KISS in general.

We're talking automatic Python to SQL type translation or NoSQL. We don't have to totally be SQL compatible! Just a scalable subset or ignore it!

Re:model changes, it's ok to ask the developer when they try to change it or have a set of sensible defaults.

Here is the challenge: The above code should work with very little modification or thinking required. Why must we put up with compromise when we know better?

It's 2010, we should be able to code scalable, simple databases in our sleep.

If you think this is important, please upvote!

解决方案

I've been busy, here it is, released under LGPL: http://github.com/lukestanley/lustdb

It uses JSON as it's backend at the moment.

This is not the same codebase Alex Martelli did. I wanted to make the code more readable and reusable with different backends and such.

Elsewhere I have been working on object oriented HTML elements accessable in Python in similar ways, AND a library for making web.py more minimalist.

I'm thinking of ways of using all 3 elements together with automatic MVC prototype construction or smart mapping.

While old fashioned text based template web programming will be around for a while still because of legacy systems and because it doesn't require any particular library or implementation, I feel soon we'll have a lot more efficent ways of building robust, prototype friendly web apps.

Please see the mailing list for those interested.

这篇关于Django模型/ SQLAlchemy膨胀!任何真正的Pythonic DB模型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆