- 
                Notifications
    
You must be signed in to change notification settings  - Fork 149
 
PostgreSQL
        Nathaniel Sabanski edited this page Jan 20, 2016 
        ·
        6 revisions
      
    by Marcos Sanchez Provencio (see this note).
You need the Npgsql data provider (included with Mono).
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:
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 CarronSee also Database Recipes and ADO.NET resources.