Python - POSTGRESS 
1) connection

#!/usr/bin/python

import psycopg2
import sys

try:
conn = psycopg2.connect('host=*** dbname=*** user=*** password=***')
print "Connected to Database"
except:
print "No Connection"


http://initd.org/psycopg/docs/usage.html

2) get_or_create


def get_or_create(session, model, **kwargs):
instance = session.query(model).filter_by(**kwargs).first()
if instance:
return instance
else:
instance = model(**kwargs)
session.add(instance)
return instance

http://stackoverflow.com/questions/6587 ... d-simultan

http://techspot.zzzeek.org/2008/09/09/s ... -booleans/

[ add comment ]   |  [ 0 trackbacks ]   |  permalink  |  related link

<<First <Back | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Next> Last>>