Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions README.es-ES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
QuickORM
========

Un ORM sencillo que proporciona una API elegante para operaciones de Python-MySQL

Conectarse a MySQL
-------------------

```python
from data_handler import Database

db_config = {
'host': 'localhost',
'port': 3306,
'user': 'root',
'password': '123456',
'database': 'test'
}
Database.connect(**db_config)
```

Definir un modelo
-----------------

```python
from data_handler import Model, Field

class TestModel(Model):
db_table = 'test'
a = Field()
b = Field()
```

Insertar
--------

```python
test = TestModel()
test.a = 5
test.b = 'john'
test.save()
```

Consultar
----------

```python
for r in TestModel.where(a=5, b='john').select():
print r.a
print r.b
```

Contar
-------

```python
print TestModel.where(a=5, b='john').count()
```

Actualizar
------------

```python
TestModel.where(a=5, b='john').update(a=1)
```

Ejecutar SQL puro
-------------------

```python
from data_handler import execute_raw_sql

results = execute_raw_sql('select b, count(*) from test where b = %s group by b;', (1,))
for val, cnt in results:
print val, cnt
```