diff --git a/README.md b/README.md index ed9c3a23..bf637473 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ sqlpp11 requires a certain api in order to connect with the database, see databa * MySQL: https://github.com/rbock/sqlpp11-connector-mysql * Sqlite3: https://github.com/rbock/sqlpp11-connector-sqlite3 * PostgreSQL: https://github.com/matthijs/sqlpp11-connector-postgresql + * ODBC: https://github.com/Erroneous1/sqlpp11-connector-odbc (experimental) To demonstrate that sqlpp11 can work with other backends as well, here is an experimental backend for structs in standard containers: diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index c4d41584..7810fa70 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -80,6 +80,11 @@ def toMemberName(s): def ddlWord(string): return WordStart(alphanums + "_") + CaselessLiteral(string) + WordEnd(alphanums + "_") +# This function should be refactored if we find some database function which needs parameters +# Right now it works only for something like NOW() in MySQL default field value +def ddlFunctionWord(string): + return CaselessLiteral(string) + OneOrMore("(") + ZeroOrMore(" ") + OneOrMore(")") + ddlString = Or([QuotedString("'"), QuotedString("\"", escQuote='""'), QuotedString("`")]) negativeSign = Literal('-') ddlNum = Combine(Optional(negativeSign) + Word(nums + ".")) @@ -98,7 +103,7 @@ ddlConstraint = Or([ ddlWord("INDEX"), ddlWord("UNIQUE"), ]) -ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments]))) +ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments]))) createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create")