by Marcos Sanchez Provencio (see this note).
You need the Npgsql data provider (included with Mono).
| Code Block |
|---|
import Npgsql
connectionString = "Server=tequila;Database=tutos;USER ID=marcos"
dbcon = NpgsqlConnection(connectionString)
dbcon.Open()
dbcmd = dbcon.CreateCommand()
sql = "SELECT firstname, lastname FROM employee"
dbcmd.CommandText = sql;
reader = dbcmd.ExecuteReader()
while reader.Read():
FirstName = reader["firstname"]
LastName = reader["lastname"]
print "Name: $FirstName $LastName"
|
Compiling and running:
| No Format |
|---|
marcos@quina:~/src/boo/bin $ ./booc.exe -r:Npgsql.dll ../examples/pruebaPostgreSQL.boo marcos@quina:~/src/boo/bin $ ./pruebaPostgreSQL.exe Name: Marcos Sanchez Provencio Name: Ernesto Molina Carron |
See also Database Recipes and ADO.NET resources.
