diff --git a/build.xml b/build.xml index 90c4d69..d441067 100644 --- a/build.xml +++ b/build.xml @@ -27,9 +27,9 @@ ${line.separator}with the full path to the 'libraries' folder inside your sketch - + - + @@ -39,6 +39,7 @@ ${line.separator}with the full path to the 'libraries' folder inside your sketch + diff --git a/examples/DuckDB_example1/DuckDB_example1.pde b/examples/DuckDB_example1/DuckDB_example1.pde new file mode 100644 index 0000000..726c717 --- /dev/null +++ b/examples/DuckDB_example1/DuckDB_example1.pde @@ -0,0 +1,31 @@ +import de.bezier.data.sql.*; + +DuckDB db; + +void setup() +{ + size( 100, 100 ); + + db = new DuckDB( this, "test.db" ); // open database file + + if ( db.connect() ) + { + // list table names + db.query( "SHOW TABLES" ); + + while (db.next()) + { + println( db.getString(1) ); + } + + // read all in table "table_one" + db.query( "SELECT * FROM table_one" ); + + while (db.next()) + { + println( db.getString("field_one") ); + println( db.getInt("field_two") ); + } + } +} + diff --git a/lib/build.number b/lib/build.number index f535698..41276ed 100644 --- a/lib/build.number +++ b/lib/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sun Jan 08 14:58:26 CET 2023 -build.number=599 +#Sat Mar 18 00:50:53 GMT 2023 +build.number=612 diff --git a/lib/duckdb_jdbc-0.7.1.jar b/lib/duckdb_jdbc-0.7.1.jar new file mode 100644 index 0000000..498473e Binary files /dev/null and b/lib/duckdb_jdbc-0.7.1.jar differ diff --git a/release/BezierSQLib.txt b/release/BezierSQLib.txt index 3a9b7bf..84bc5bd 100644 --- a/release/BezierSQLib.txt +++ b/release/BezierSQLib.txt @@ -4,5 +4,5 @@ url = https://github.com/fjenett/sql-library-processing category = Data sentence = A library to facilitate communication with SQL-based databases paragraph = SQLibrary is an interface to MySQL, SQLite and PostgreSQL databases -version = 1192 -prettyVersion = 0.3.2 \ No newline at end of file +version = 1206 +prettyVersion = 0.3.3 \ No newline at end of file diff --git a/release/BezierSQLib.zip b/release/BezierSQLib.zip index ce506cf..9d8f6c6 100644 Binary files a/release/BezierSQLib.zip and b/release/BezierSQLib.zip differ diff --git a/resources/build.number b/resources/build.number index 3464fae..f479d11 100644 --- a/resources/build.number +++ b/resources/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sun Jan 08 14:58:26 CET 2023 -build.number=1194 +#Sat Mar 18 00:50:53 GMT 2023 +build.number=1207 diff --git a/src/de/bezier/data/sql/DuckDB.java b/src/de/bezier/data/sql/DuckDB.java new file mode 100644 index 0000000..5d12088 --- /dev/null +++ b/src/de/bezier/data/sql/DuckDB.java @@ -0,0 +1,59 @@ +package de.bezier.data.sql; + +import processing.core.*; +import java.util.ArrayList; + +/** + * DuckDB wrapper for SQL library for Processing 2+ + */ +public class DuckDB + extends de.bezier.data.sql.SQL +{ + /** + * Creates a new DuckDB connection. + * + * @param _papplet Your sketch, pass "this" in here + * @param _database Path to the database file, if this is just a name the data and sketch folders are searched for the file + */ + public DuckDB ( PApplet _papplet, String _database ) + { + super( _papplet, _database ); + init(); + } + + /** + * Creates a new DuckDB connection, same as DuckDB( PApplet, String ) + * + * @param _papplet Your sketch, pass "this" in here + * @param _server Ignored + * @param _database Path to the database file, if this is just a name the data and sketch folders are searched for the file + * @param _user Ignored + * @param _pass Ignored + */ + public DuckDB ( PApplet _papplet, String _server, String _database, String _user, String _pass ) + { + this( _papplet, _database ); + } + + + private void init () + { + this.driver = "org.duckdb.DuckDBDriver"; + this.type = "duckdb"; + + this.url = "jdbc:" + type + ":" + database; + } + + public String[] getTableNames () + { + if ( tableNames == null ) + { + tableNames = new ArrayList(); + query( "SHOW TABLES" ); + while ( next() ) { + tableNames.add( getObject(1).toString() ); + } + } + return tableNames.toArray(new String[0]); + } +}