Sqlite.hx 550 B

1234567891011121314151617181920212223
  1. package sys.db;
  2. class Sqlite
  3. {
  4. static var init = false;
  5. /**
  6. Opens a new SQLite connection on the specified path.
  7. Note that you will need a SQLite JDBC driver (like https://bitbucket.org/xerial/sqlite-jdbc).
  8. **/
  9. public static function open(file:String):sys.db.Connection
  10. {
  11. if (!init)
  12. {
  13. try java.lang.Class.forName("org.sqlite.JDBC") catch(e:Dynamic) throw e;
  14. init = true;
  15. }
  16. try
  17. {
  18. var cnx = java.sql.DriverManager.getConnection("jdbc:sqlite:" + file);
  19. return java.db.Jdbc.create(cnx);
  20. } catch(e:Dynamic) throw e;
  21. }
  22. }