ध्यान दें:time.Time को सही तरीके से हैंडल करने के लिए, आपको parseTime को एक पैरामीटर के रूप में शामिल करना होगा। (अधिक पैरामीटर) UTF-8 एन्कोडिंग का पूर्ण समर्थन करने के लिए, आपको charset=utf8 को charset=utf8mb4 में बदलना होगा। विस्तृत व्याख्या के लिए यह लेख देखें
MySQL ड्राइवर कुछ advanced कॉन्फ़िगरेशन प्रदान करता है, जिसका उपयोग initialization के दौरान किया जा सकता है, उदाहरण के लिए:
db, err := gorm.Open(mysql.New(mysql.Config{ DSN: "gorm:gorm@tcp(127.0.0.1:3306)/gorm?charset=utf8&parseTime=True&loc=Local", // data source name //डेटा स्रोत का नाम DefaultStringSize: 256, // default size for string fields //स्ट्रिंग फ़ील्ड के लिए डिफ़ॉल्ट आकार DisableDatetimePrecision: true, // disable datetime precision, which not supported before MySQL 5.6 /डेटाटाइम परिशुद्धता अक्षम करें, जो MySQL 5.6 से पहले समर्थित नहीं है DontSupportRenameIndex: true, // drop & create when rename index, rename index not supported before MySQL 5.7, MariaDB // निर्दिष्ट का नाम बदलने पर बनाएँ, MySQL 5.7, MariaDB से पहले संगति का नाम परिवर्तन नहीं होता है DontSupportRenameColumn: true, // `change` when rename column, rename column not supported before MySQL 8, MariaDB // // `परिवर्तन` जब स्तंभ का नाम बदलें, नाम बदलें कॉलम MySQL 8, MariaDB से पहले समर्थित नहीं है SkipInitializeWithVersion: false, // auto configure based on currently MySQL version //वर्तमान में MySQL संस्करण के आधार पर ऑटो कॉन्फ़िगर करें }), &gorm.Config{})
ड्राइवर को अनुकूलित करें //Customize Driver
GORM MySQL ड्राइवर को DriverName विकल्प के साथ अनुकूलित करने की अनुमति देता है, उदाहरण के लिए:
हम pgx का उपयोग पोस्टग्रेज के डेटाबेस/एसक्यूएल ड्राइवर के रूप में कर रहे हैं, यह इसे निष्क्रिय करने के लिए डिफ़ॉल्ट रूप से तैयार स्टेटमेंट कैश को सक्षम करता है:
The GORM Driver for Oracle provides support for Oracle Database, enabling full compatibility with GORM’s ORM capabilities. It is built on top of the Go Driver for Oracle (Godror) and supports key features such as auto migrations, associations, transactions, and advanced querying.
Prerequisite: Install Instant Client
To use ODPI-C with Godror, you’ll need to install the Oracle Instant Client on your system. Follow the steps on this page to complete the installation.
After that, you can connect to the database using the dataSourceName, which specifies connection parameters (such as username and password) using a logfmt-encoded parameter list.
The way you specify the Instant Client directory differs by platform:
macOS and Windows: You can set the libDir parameter in the dataSourceName.
Linux: The libraries must be in the system library search path before your Go process starts, preferably configured with “ldconfig”. The libDir parameter does not work on Linux.
import ( "gorm.io/driver/sqlite"// Sqlite driver based on CGO // "github.com/glebarez/sqlite" // Pure go SQLite driver, checkout https://github.com/glebarez/sqlite for details "gorm.io/gorm" )