PGSQLKit for Mac & iOS

Lost in the shuffle of setting up a database server is the question of getting data in and out of it. Usually, the need for a database comes from an application, but how do developer's get to that database?

How you get to the database largely depends upon your needs and toolset. At the most basic is the C API found in libpq, as provided by PostgreSQL. From there, the choices are many. For Java applications, the distribution has a JDBC driver. There are several commercial and open source ODBC options as well. But what about a toolkit for the Cocoa developer? There are a couple of options there as well.

For the Objective-C developer, we have our own answer. PGSQLKit is a framework for the Cocoa development environment. This is an Objective-C framework written with the intent of being Cocoa like, but also readily approachable by the developer familiar with JDBC, .Net or Microsoft's ADO API's. This framework also adheres to our 'GenDB' specification which allows a Cocoa developer to drop in replace a PGSQLKit framework with ODBCKit or in the future our TDSKit and others as we expand the platform.

Licensing

One of the questions that is most often asked is licensing. The short version is that while the PGSQLKit is not Public Domain, it is as close as a license can get. It is a BSD style license, that grants you to redistribute it provided you keep the original copyright on with it. It further states that our name may not be used to endorse any product built using it. Other than that, have at it. The intent has always been to provide a toolkit to make it easier to build PostgreSQL based applications on the Mac. This is not a multi-page legal contract. [View License]

Using

Using Swift:

        var conn: GenDBConnection;
        conn = PGSQLConnection();
        
        var connectionString: String
        connectionString = "host=" + hostName.text
        connectionString += " port=" + port.text
        connectionString += " dbname=" + database.text
        connectionString += " user=" + userName.text
        connectionString += " password=" + password.text
        
        conn.ConnectionString = connectionString
        if (!conn.connect())
        {
            println("Connection Failed");
            println(conn.LastError);
            conn.close()
        } else {
            println("Connected")
            
            results.text = "Connected"
            
            var rs: GenDBRecordset?
            rs = conn.open("select * from pg_Tables")
            var rowCount = rs!.rowCount()
            println("recordcount \(rowCount)")
            if (rs!.IsEOF)
            {
                println("No Result Found")
                output.text = "No Results found"
            }
            output.text = ""
            while (!rs!.IsEOF)
            {
                var tableName = rs!.fieldByName("tablename").asString()
                println("Table Named: \(tableName)")
                output.text = "Table Named: \(tableName) \n" + output.text!
                rs!.moveNext()
            }
            
            rs!.close()
            conn.close();
        }
									


History

10/30/2015 - 9.3.1

Released separate from the universal installation.

  • Updated libpq to 9.3.1
  • Major updates to make better Swift compat
  • Fixed issues that blocked use under 10.11

  • 10/12/2011 - 9.1.1 Release 1

    Released as part of the Universal installer, this is now also available here.

  • Updated libpq to 9.1.1
  • released as part of Universal Installer.
  • began GenDB implementation and migration for enQuery
  • Updated iOS package to support iOS 4.3
  • Updated iOS package to suppost Xcode 4.1

  • 9.1.0 Release 1

    This is the same code as was released in the Unified installer, and as such can be used from there as well All of the changes reflected there are also here. At this point this release is intended to simply mark the placeholder as we move to supporting the library here.



    News
    Downloads @ Druware

    PostgreSQL Resources