Project

General

Profile

AQuickTutorial » History » Version 3

Aurynn Shaw, 11/20/2008 01:37 PM

1 1 Aurynn Shaw
= Simpycity in a Hurry =
2
And what to expect when you use it.
3
4
== Setup ==
5
6
First, set up Simpycity:
7
8
{{{
9 2 Aurynn Shaw
from simpycity.core import Function
10 1 Aurynn Shaw
from simpycity import config
11
12
config.host = 'localhost'
13
config.port = 5432
14 2 Aurynn Shaw
config.user = 'user'
15
config.password = 'password'
16
config.database = 'dbname'
17
18
}}}
19
20
Then, create some basic functions.
21
{{{
22
f_all = Function("get_row",['id'])
23
f = Function("get_rows")
24
}}}
25
26 3 Aurynn Shaw
'''f_all''' maps to the stored procedure "get_rows", which takes no arguments.
27 2 Aurynn Shaw
28 3 Aurynn Shaw
'''f''', on the other hand, maps to the stored procedure "get_row", which takes a single argument, which we've named id.
29 2 Aurynn Shaw
30 3 Aurynn Shaw
To call f_all, it's a standard python function:
31 1 Aurynn Shaw
{{{
32
all_results = f_all()
33 3 Aurynn Shaw
}}}
34
35
For get_row, it's the same Python call semantics, both positional and keyword arguments being supported
36
{{{
37
result = f(1) # get id 1
38
result = f(id=1) # also get id 1
39 1 Aurynn Shaw
}}}