{"id":16327418,"url":"https://github.com/subztep/sqlitemanager","last_synced_at":"2025-10-25T20:32:28.290Z","repository":{"id":78821205,"uuid":"103680126","full_name":"SubZtep/SQLiteManager","owner":"SubZtep","description":"Unity3D SQLite Manager","archived":false,"fork":false,"pushed_at":"2018-06-17T12:52:17.000Z","size":1182,"stargazers_count":8,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-31T10:36:07.079Z","etag":null,"topics":["data","database","plugin","script","sqlite","unity","unity3d","wrapper"],"latest_commit_sha":null,"homepage":null,"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/SubZtep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-15T16:47:37.000Z","updated_at":"2023-05-06T11:59:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"d588922f-e5dd-4771-a4ea-33b875e921af","html_url":"https://github.com/SubZtep/SQLiteManager","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SubZtep%2FSQLiteManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SubZtep%2FSQLiteManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SubZtep%2FSQLiteManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SubZtep%2FSQLiteManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SubZtep","download_url":"https://codeload.github.com/SubZtep/SQLiteManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238207661,"owners_count":19434095,"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":["data","database","plugin","script","sqlite","unity","unity3d","wrapper"],"created_at":"2024-10-10T23:11:24.067Z","updated_at":"2025-10-25T20:32:22.750Z","avatar_url":"https://github.com/SubZtep.png","language":"C#","readme":"SQLite Manager\r\n==============\r\n\r\n[![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/SubZtep/SQLiteManager/blob/master/LICENSE) [![Alpha Stage](https://img.shields.io/badge/stage-alpha-green.svg)](https://github.com/SubZtep/SQLiteManager/blob/master/README.md) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)\r\n\r\n## Welcome\r\n\r\n**Adopt Database in Unity3D!** ***SQLite Manager*** make easy to read and update your local data. Use a real database to store environment data, player settings, gameplay variables or whatever is in your mind. Query with SQL from simple schema is much easier than manipulate local textfiles for the same reason.\r\n\r\n## Speed Test\r\n\r\n****TODO:**** Everything!\r\n\r\n## Warning\r\n\r\n_Under development, the syntax might change in the future. Although I try to make it safe please use it at your own risk, I haven’t used it in production yet._\r\n\r\nTested only with **Unity 2018.1.1f1 for Windows**, *Linux/Mac/Mobile* support is under blockchain kripto’er. (sic)\r\n\r\n## What Is This\r\n\r\nA C# wrapper class around Mono’s SQLite functions to make it easier and faster to use.\r\n\r\n## Simple Example\r\n\r\nFind some basic codes with the plugin. Check out [the test file](https://github.com/SubZtep/SQLiteManager/blob/master/Assets/DemoLand/SQLiteManager/Tests/Editor/SQLiteManagerTest.cs) for more usage example.\r\n\r\n- Init database\r\n\t```csharp\r\n\tSQLiteManager db;\r\n\ttry {\r\n\t\tdb = new SQLiteManager(\"Game.db\");\r\n\t} catch (SqliteException e) {\r\n\t\tDebug.Log(\"Sqlite exception: \" + e.Message);\r\n\t}\r\n\t```\r\n\r\n- Create a class (for examples below)\r\n\t```csharp\r\n\tpublic class User\r\n\t{\r\n\t\tpublic int UserID { get; set; }\r\n\t\tpublic string Name { get; set; }\r\n\t}\r\n\t```\r\n\r\n- Run native SQL query\r\n\t```csharp\r\n\tusing (IDbCommand dbcmd = db.Connection.CreateCommand()) {\r\n\t\tdbcmd.CommandText = \"INSERT INTO `User` (`UserId`, `Name`) VALUES (1, 'John Doe'), (2, 'Jane Doe');\";\r\n\t\tdbcmd.ExecuteNonQuery();\r\n\t}\r\n\t```\r\n\r\n- Get one row\r\n\t```csharp\r\n\tUser user = db.GetObj\u003cUser\u003e(1);\r\n\tUser user = db.GetObj\u003cUser\u003e(\"SELECT * FROM User WHERE UserID = 1\");\r\n\t```\r\n\r\n- Get multiple rows\r\n\t```csharp\r\n\tList\u003cUser\u003e users = db.GetObjList\u003cUser\u003e(\"SELECT * FROM User\");\r\n\t```\r\n\r\n## Example Workflow\r\n\r\nWe gonna store the database connection variable in a static class, the connection will be always available for a command regardless of the scene. All the steps of this workflow already exist on project _SampleScreen_.\r\n\r\n1. **Unity Settings**\r\n\r\n\tUse creaky C# version. Go to menu ***_File, Build Settings..., Player Settings..., Other Settings, Scripting Runtime Version_*** and set to recent **.NET 4.x Equivalent**.\r\n\r\n2. **Add Container**\r\n\r\n\tTo achieve connection container use **[PersistData](https://github.com/SubZtep/PersistData)**. It’s a basic but effective class of mine just handy to store anything in a _HashMap_. Included to this repository.\r\n\r\n\tCreate a new empty game object, name it _Persist Data_. In the Inspector window select ***Add Component, Miscellaneous, Persist Data*** for initialising the static class.\r\n\r\n3. **Create Database**\r\n\r\n\tThere is no plan to create an enormous database admin inside the Unity editor in the near future by me. It would be pointless. There is plenty of 3rd party software for this job. Just find one you like, install it and get ready to create your game **.db** file. The entire database is in a single file, just think about how simple will be its online synchronisation.\r\n\r\n\tI recommend using **[DB Browser for SQLite](http://sqlitebrowser.org/)** open source desktop app. Very straightforward, create a new database, create the schema and insert potential initial records.\r\n\r\n\tCreate or open the **Streaming Assets** folder into your *Assets* directory. Copy here your *Game.db* file.\r\n\r\n4. **Wake Up Database**\r\n\r\n\tCreate a new empty game object, name it _Game Manager_. Create _InitPersistData.cs_ script and connect to the SQLite database at the start.\r\n\r\n\t```csharp\r\n\tif (!PersistData.Instance.Has(PDKey.Database)) {\r\n\t\tSQLiteManager db = null;\r\n\t\tUseDatabase udb = GetComponent\u003cUseDatabase\u003e();\r\n\r\n\t\ttry {\r\n\t\t\tdb = new SQLiteManager(udb.GetDatabaseFilePath());\r\n\t\t} catch (Exception e) {\r\n\t\t\tudb.UnselectBinary();\r\n\t\t\tDebug.LogException(e);\r\n\t\t}\r\n\r\n\t\tif (db.IsOpen()) {\r\n\t\t\tPersistData.Instance.Set(PDKey.Database, db);\r\n\t\t}\r\n\t}\r\n\t```\r\n\r\n\tDrop _InitPersistData.cs_ script to the _Game Manager_ Inspector window.\r\n\r\n5. **Create Helper Class**\r\n\r\n\tCreate _PD.cs_ script and add a shorter connection syntax for SQLite.\r\n\r\n\t```csharp\r\n\tpublic static SQLiteManager Database() {\r\n\t\treturn (SQLiteManager)PersistData.Instance.Get(PDKey.Database);\r\n\t}\r\n\t```\r\n\r\n\tDrop _PD.cs_ script to the _Game Manager_ Inspector window.\r\n\r\n6. **Additional Component**\r\n\r\n\tIf you'd like to test the connection or get disappointed of lack of functions just simply add this component ***Add Component, SQLite Manager, Manage Database***. This component has a chance to become big.\r\n\r\n7. **Ready To Use**\r\n\r\n\tAt this point, your database should be ready to use without any error message on the Console window. _Game Manager_ Inspector window should look like below.\r\n\r\n\t![Components on Inspector window](https://cdn.rawgit.com/SubZtep/SQLiteManager/279412aa/docs/img/plugin_screen.png?raw=true)\r\n\r\n## Example Code Snippets\r\n\r\n- Required Imports\r\n\t```csharp\r\n\tusing DemoLand.PersistData;\r\n\tusing DemoLand.SQLiteManager;\r\n\t```\r\n\r\n- Set database instance\r\n\t```csharp\r\n\tPersistData.Instance.Set(\"db\", db);\r\n\t```\r\n\r\n- Get data\r\n\t```csharp\r\n\tstring data = ((SQLiteManager)PersistData.Instance.Get(\"db\")).GetObj\u003cUser\u003e(1).Name;\r\n\t```\r\n\r\n## Available Methods\r\n\r\nRaw public method list, more info in the source code.\r\n\r\n- **Connection**\r\n\t- Connection\r\n\t- SQLiteManager\r\n\t- Connect\r\n\t- Close\r\n\t- IsOpen\r\n\r\n- **Getter Methods**\r\n\t- GetObj\r\n\t- GetObjList\r\n\t- GetTableNames\r\n\t- GetResultReader\r\n\r\n- **Data Manipulation Methods**\r\n\t- SaveObj\r\n\t- TruncateTable\r\n\t- BuildObj\r\n\t- ColumnExists\r\n\t- GetParsedSql\r\n\r\n## Versioning\r\n\r\nThe first version will come with the first release, once all the essential functions are there.\r\n\r\n[![ForTheBadge built-with-love](http://ForTheBadge.com/images/badges/built-with-love.svg)](https://GitHub.com/SubZtep/)\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubztep%2Fsqlitemanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubztep%2Fsqlitemanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubztep%2Fsqlitemanager/lists"}