-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mysqlclient 8.0.31: Major update of the library (#38)
- Loading branch information
1 parent
2f041f3
commit 49dbc47
Showing
3,669 changed files
with
399,636 additions
and
217,571 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Documentation | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
|
||
env: | ||
DEVELOPER_DIR: /Applications/Xcode_14.0.1.app/Contents/Developer | ||
|
||
jobs: | ||
Generate: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Generate archive | ||
run: | | ||
xcodebuild docbuild \ | ||
-scheme 'OHMySQL' \ | ||
-derivedDataPath ./build \ | ||
-destination 'platform=iOS Simulator,OS=latest,name=iPhone 13' | ||
- name: Generate pages | ||
run: | | ||
$(xcrun --find docc) process-archive transform-for-static-hosting \ | ||
$(find ./build -type d -name '*.doccarchive') \ | ||
--hosting-base-path OHMySQL \ | ||
--output-path ./docs | ||
- name: Deploy documentation to Github Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./docs | ||
keep_files: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Getting Started | ||
|
||
Set up the classes that manage and persist your data. | ||
|
||
## Overview | ||
|
||
* An instance of ``OHMySQLConfiguration`` represents your connection preferences. | ||
* An instance of ``OHMySQLStoreCoordinator`` manages a connection to the database. | ||
* An instance of ``OHMySQLQueryContext`` saves and fetches data from storage, executes the queries. | ||
|
||
### Initialize a Store Coordinator | ||
|
||
Typically, you need to keep only one instance of ``OHMySQLStoreCoordinator`` in your code. One instance is a one connection. | ||
|
||
1. Create configuration preference instance: | ||
```swift | ||
let configuration = MySQLConfiguration(userName: "root", password: "root", serverName: "localhost", dbName: "db_name", port: 3306, socket: "/mysql/mysql.sock") | ||
``` | ||
If your connection is configured for SSL, you can specify this at creation: | ||
```swift | ||
let sslConfig = MySQLSSLConfig(key: "client-key.pem", certPath: "client-cert.pem", certAuthPath: "ca.pem", certAuthPEMPath: "", cipher: nil) | ||
let configuration = MySQLConfiguration(userName: "root", password: "root", sslConfig: sslConfig, serverName: "localhost", dbName: "db_name", port: 3306, socket: "/mysql/mysql.sock") | ||
``` | ||
|
||
2. Create a store coordinator. | ||
```swift | ||
let coordinator = MySQLStoreCoordinator(user: configuration) | ||
``` | ||
|
||
If required, you can set up the encoding and protocol type. | ||
```swift | ||
coordinator.encoding = .UTF8MB4 | ||
coordinator.protocol = .TCP | ||
``` | ||
|
||
3. Connect to the database. The method ``OHMySQLStoreCoordinator/connect`` returns a boolean value indicating if a connection is set up. | ||
```swift | ||
if coordinator.connect() { | ||
print("Connected successfully.") | ||
} | ||
``` | ||
|
||
### Configure Query Context | ||
|
||
The instance of ``OHMySQLQueryContext`` is responsible for executing queries, saving/updating/deleting model objects. It is a key object in the application. | ||
|
||
1. There must be only one **main** context in the application. | ||
```swift | ||
let context = MySQLQueryContext() | ||
``` | ||
|
||
2. The context must keep a reference to store coordinator. | ||
```swift | ||
context.storeCoordinator = coordinator | ||
``` | ||
|
||
3. For your convenience, set a context into singleton of ``OHMySQLContainer``. | ||
```swift | ||
MySQLContainer.shared.mainQueryContext = context | ||
``` | ||
|
||
You can always access the main context in any place of your code: | ||
```swift | ||
MySQLContainer.shared.mainQueryContext?.lastInsertID() | ||
``` | ||
|
||
### Execute Query | ||
|
||
Every query is represented by a string. An instance of ``OHMySQLQueryRequest`` initialized with a string and provides timeline information after execution. | ||
|
||
Typically, there are two types of queries. | ||
The first type doesn't return any result. It executes the query and you can catch the error if any appears. | ||
|
||
```swift | ||
let queryString = "DROP TABLE `mytable`" | ||
let queryRequest = MySQLQueryRequest(queryString: dropQueryString) | ||
|
||
do { | ||
try MySQLContainer.shared.mainQueryContext?.execute(dropQueryRequest) | ||
} catch { | ||
print("Cannot execute the query.") | ||
} | ||
``` | ||
|
||
The second type does return a result. The result is an array of dictionaries. | ||
```swift | ||
let queryString = "SELECT * FROM `mytable`" | ||
let queryRequest = MySQLQueryRequest(queryString: queryString) | ||
do { | ||
let result = try MySQLContainer.shared.mainQueryContext?.executeQueryRequestAndFetchResult(query) ?? [] | ||
print("\(result)") | ||
} catch { | ||
print("Cannot execute the query.") | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Installation | ||
|
||
Learn the ways to integrate the framework in your application. | ||
|
||
## Overview | ||
|
||
The framework can be installed in different ways. | ||
|
||
### CocoaPods | ||
|
||
Open `Podfile` and declare the dependency: | ||
```bash | ||
pod 'OHMySQL' | ||
``` | ||
|
||
Then open Terminal, navigate to project folder and install the dependencies: | ||
``` | ||
pod install --repo-update | ||
``` | ||
|
||
> Tip: Learn how to use [CocoaPods](https://guides.cocoapods.org/using/getting-started.html). | ||
### Carthage | ||
|
||
Add the following to your `Cartfile`: | ||
```bash | ||
github "oleghnidets/OHMySQL" | ||
``` | ||
|
||
Run the command for updating Carthage dependencies. | ||
``` | ||
carthage update --use-xcframeworks OHMySQL | ||
``` | ||
|
||
In addition to manually adding xcframework of OHMySQL from `Carthage/Build` folder you will need to add manually `MySQL.xcframework`. `MySQL.xcframework` is a part of this repo, see `OHMySQL/lib/MySQL.xcframework`. | ||
|
||
> Tip: Learn how to use [Carthage](https://github.com/Carthage/Carthage#quick-start). | ||
### Manually | ||
|
||
Open up Terminal and clone the repo. | ||
``` | ||
git clone https://github.com/oleghnidets/OHMySQL | ||
``` | ||
|
||
Open cloned repo folder and copy the folder `OHMySQL`. Paste the folder into your project folder. | ||
|
||
Open up your project (xcodeproj) and drag the folder `OHMySQL` into the Project Navigator of your application's Xcode project. | ||
|
||
Navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar. In the tab bar at the top of that window, open the "General" panel. Make sure there is the framework `MySQL.xcframework` under the "Frameworks & Libraries" section. If not, click on the `+` button and add the framework. Also, you will need to add the library `libc++`. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# ``OHMySQL`` | ||
|
||
The framework allows to establish a connection with MySQL database. The framework supports Objective-C and Swift, iOS, macOS, Catalyst, tvOS, watchOS. | ||
|
||
## Overview | ||
|
||
OHMySQL can connect to remote or local MySQL database and execute CRUD operations. The framework is built upon MySQL C API, but you don't need to dive into low-level. | ||
The following diagram represents a general architecture. Logic (saving, editing, removing etc.) is aggregated in the app. The database is just a shared storage. | ||
|
||
![Simple Diagram](diagram.png) | ||
|
||
## Topics | ||
|
||
### Essentials | ||
|
||
- <doc:Installation> | ||
- <doc:GettingStarted> | ||
|
||
### Setup connection | ||
|
||
- ``OHMySQLConfiguration`` | ||
- ``OHSSLConfig`` | ||
- ``OHMySQLStoreCoordinator`` | ||
- ``OHMySQLContainer`` | ||
- ``OHMySQLQueryContext`` | ||
|
||
### Execute Query | ||
|
||
- ``OHMySQLQueryRequest`` | ||
- ``OHMySQLQueryRequestFactory`` | ||
|
||
### Object Mapping | ||
|
||
- ``OHMySQLMappingProtocol`` | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.