{"id":15002481,"url":"https://github.com/martinrybak/sqlclient","last_synced_at":"2025-08-22T05:32:03.269Z","repository":{"id":11214433,"uuid":"13602107","full_name":"martinrybak/SQLClient","owner":"martinrybak","description":"Native Microsoft SQL Server client for iOS","archived":false,"fork":false,"pushed_at":"2019-09-25T12:15:05.000Z","size":6071,"stargazers_count":120,"open_issues_count":14,"forks_count":50,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-04-26T13:21:03.953Z","etag":null,"topics":["freetds","ios","microsoft-sql-server","sql-server"],"latest_commit_sha":null,"homepage":"http://objcsharp.wordpress.com/2013/10/15/an-open-source-sql-server-library-for-ios/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/martinrybak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-15T20:59:18.000Z","updated_at":"2024-02-20T17:14:37.000Z","dependencies_parsed_at":"2022-09-14T12:51:43.019Z","dependency_job_id":null,"html_url":"https://github.com/martinrybak/SQLClient","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinrybak%2FSQLClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinrybak%2FSQLClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinrybak%2FSQLClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinrybak%2FSQLClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinrybak","download_url":"https://codeload.github.com/martinrybak/SQLClient/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230561014,"owners_count":18245324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["freetds","ios","microsoft-sql-server","sql-server"],"created_at":"2024-09-24T18:50:40.252Z","updated_at":"2024-12-20T09:07:13.437Z","avatar_url":"https://github.com/martinrybak.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"SQLClient\n=========\n\nNative Microsoft SQL Server client for iOS. An Objective-C wrapper around the open-source [FreeTDS](https://github.com/FreeTDS/freetds/) library.\n\n## Sample Usage\n\n\u003cpre\u003e\n\u0026#35;import \"SQLClient.h\"\n\nSQLClient* client = [SQLClient sharedInstance];\n[client connect:@\"server\\instance:port\" username:@\"user\" password:@\"pass\" database:@\"db\" completion:^(BOOL success) {\n    if (success) {\n      [client execute:@\"SELECT * FROM Users\" completion:^(NSArray* results) {\n        for (NSArray* table in results) {\n          for (NSDictionary* row in table) {\n            for (NSString* column in row) {\n              NSLog(@\"%@=%@\", column, row[column]);\n            }\n          }\n        }             \n        [client disconnect];\n      }];\n    }\n}];\n\u003c/pre\u003e\n\n## Errors\n\nFreeTDS communicates both errors and messages. `SQLClient` rebroadcasts both via `NSNotificationCenter`:\n\n```\n[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(error:) name:SQLClientErrorNotification object:nil];\n[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(message:) name:SQLClientMessageNotification object:nil];\t\n\n- (void)error:(NSNotification*)notification\n{\n\tNSNumber* code = notification.userInfo[SQLClientCodeKey];\n\tNSString* message = notification.userInfo[SQLClientMessageKey];\n\tNSNumber* severity = notification.userInfo[SQLClientSeverityKey];\n\tNSLog(@\"Error #%@: %@ (Severity %@)\", code, message, severity);\n}\n\n- (void)message:(NSNotification*)notification\n{\n\tNSString* message = notification.userInfo[SQLClientMessageKey];\n\tNSLog(@\"Message: %@\", message);\n}\n```\n\n## Type Conversion\nSQLClient maps SQL Server data types into the following native Objective-C types:\n\n* bigint → NSNumber\n* binary(n) → NSData\n* bit → NSNumber\n* char(n) → NSString\n* cursor → **not supported**\n* date → **NSDate** or **NSString**†\n* datetime → NSDate\n* datetime2 → **NSDate** or **NSString**†\n* datetimeoffset → **NSDate** or **NSString**†\n* decimal(p,s) → NSNumber\n* float(n) → NSNumber\n* image → **NSData**\n* int → NSNumber\n* money → NSDecimalNumber **(last 2 digits are truncated)**\n* nchar → NSString\n* ntext → NSString\n* null → NSNull\n* numeric(p,s) → NSNumber\n* nvarchar → NSString\n* nvarchar(max) → NSString\n* real → NSNumber\n* smalldatetime → NSDate\n* smallint → NSNumber\n* smallmoney → NSDecimalNumber\n* sql_variant → **not supported**\n* table → **not supported**\n* text → NSString*\n* time → **NSDate** or **NSString**†\n* timestamp → NSData\n* tinyint → NSNumber\n* uniqueidentifier → NSUUID\n* varbinary → NSData\n* varbinary(max) → NSData\n* varchar(max) → NSString*\n* varchar(n) → NSString\n* xml → NSString\n\n\\*The maximum length of a string in a query is configured on the server via the `SET TEXTSIZE` command. To find out your current setting, execute `SELECT @@TEXTSIZE`. SQLClient uses **4096** by default. To override this setting, update the `maxTextSize` property.\n\n†The following data types are only converted to **NSDate** on TDS version **7.3** and higher. By default FreeTDS uses version **7.1** of the TDS protocol, which converts them to **NSString**. To use a higher version of the TDS protocol, add an environment variable to Xcode named `TDSVER`. Possible values are\n`4.2`, `5.0`, `7.0`, `7.1`, `7.2`, `7.3`, `7.4`, `auto`.\nA value of `auto` tells FreeTDS to use an autodetection (trial-and-error) algorithm to choose the highest available protocol version.\n\n* date\n* datetime2\n* datetimeoffset\n* time\n\n## Testing\n\nThe `SQLClientTests` target contains integration tests which require a connection to an instance of SQL Server. The integration tests have passed successfully on the following database servers:\n\n* SQL Server 7.0 (TDS 7.0)\n* SQL Server 2000 (TDS 7.1)\n* SQL Server 2005 (TDS 7.2)\n* SQL Server 2008 (TDS 7.3)\n* **TODO: add more!**\n\nTo configure the connection for your server:\n\n* In Xcode, go to `Edit Scheme...` and select the `Test` scheme.\n* On the `Arguments` tab, uncheck `Use the Run action's arguments and environment variables`\n* Add the following environment variables for your server. The values should be the same as you pass in to the `connect:` method.\n\t* `HOST` (`server\\instance:port`)\n\t* `DATABASE` (optional)\n\t* `USERNAME`\n\t* `PASSWORD`\n\n## Known Issues\nPR's welcome!\n\n* **strings**: FreeTDS incorrectly returns an empty string \"\" for a single space \" \"\n* **money**: FreeTDS will truncate the rightmost 2 digits.\n* OSX support: [FreeTDS-iOS](https://github.com/martinrybak/FreeTDS-iOS) needs to be compiled to support OSX and Podspec updated\n* No support for stored procedures with out parameters (yet)\n* No support for returning number of rows changed (yet)\n* Swift bindings: I welcome a PR to make the API more Swift-friendly\n\n##Demo Project\nOpen the Xcode project inside the **SQLClient** folder.\n\n\n## Installation\n\n### CocoaPods\n\n\u003ca href=\"http://cocoapods.org/?q=sqlclient\"\u003eCocoaPods\u003c/a\u003e is the preferred way to install this library.\n\n1. Open a Terminal window. Update RubyGems by entering: `sudo gem update --system`. Enter your password when prompted.\n2. Install CocoaPods by entering `sudo gem install cocoapods`.\n3. Create a file at the root of your Xcode project folder called **Podfile**.\n4. Enter the following text: `pod 'SQLClient', '~\u003e 1.0.0'`\n4. In Terminal navigate to this folder and enter `pod install`.\n5. You will see a new **SQLClient.xcworkspace** file. Open this file in Xcode to work with this project from now on.\n\n### Manual\n\n1. Drag and drop the contents of the **SQLClient/SQLClient/SQLClient** folder into your Xcode project.\n2. Select **Copy items into destination group's folder (if needed)**.\n3. Go to Project \u003e Build Phases \u003e Link Binary With Libraries.\n3. Click + and add **libiconv.dylib**.\n\n## Documentation\n\n\u003ca href=\"http://htmlpreview.github.io/?https://raw.github.com/martinrybak/SQLClient/master/SQLClient/SQLClientDocs/html/index.html\"\u003eSQLClient Class Reference\u003c/a\u003e\n\n\u003ca href=\"http://wp.me/p3o7rD-cY\"\u003eSQLClient: A Native Microsoft SQL Server Library for iOS\u003c/a\u003e\n\n## Credits\n\nFreeTDS:\nhttp://www.freetds.org\n\nFreeTDS-iOS:\nhttps://github.com/patchhf/FreeTDS-iOS\n\nFreeTDS example code in C:\nhttp://freetds.schemamania.org/userguide/samplecode.htm\n\nSQL Server Logo\n© Microsoft\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinrybak%2Fsqlclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinrybak%2Fsqlclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinrybak%2Fsqlclient/lists"}