Пример #1
0
        static void Main(string[] args)
        {
            var db = new ClickHouseDatabase(
                new ClickHouseConnectionSettings("Compress=True;CheckCompressedHash=False;Compressor=lz4;Host=192.168.0.163;Port=9000;User=default;Password=;SocketTimeout=600000;Database=TeasersStat;"),
                new ClickHouseCommandFormatter(),
                new ClickHouseConnectionFactory(),
                null,
                new DefaultPropertyBinder());

            /*
             * db.Open();
             * db.BackupDatabase("TeasersStat");
             * db.Close();
             */
            var columns = db.DescribeTable("LastTeasersShows").ToArray();


            /* Get data using default binder
             * db.Open();
             * for (int i = 0; i < 10; i++)
             * {
             *  var res = db.DatabaseExists("test");
             *  Console.WriteLine($"Database test exists: {res}");
             * }
             *
             * // Execute query and get result
             * var queryMappingSuccess = CastRawValuesToClassTypeProperties(db);
             * db.Close();
             */

            /* Using custom binder */
            /*CustomBinderDemo();*/
        }
Пример #2
0
 public static IEnumerable <T> Read <T>(this ClickHouseConnection conn, string commandText) where T : new()
 {
     using (ClickHouseDatabase db = conn.CreateDatabase())
     {
         return(db.Read <T>(commandText));
     }
 }
Пример #3
0
        public static IEnumerable <T> Read <T>(this ClickHouseDatabase db, string commandText) where T : new()
        {
            ProxyLog.Info(commandText);
            var entities = db.ExecuteQueryMapping <T>(commandText);

            ProxyLog.Info($"{entities.Count()} row(s)");
            return(entities);
        }
Пример #4
0
 public AppsController(AppStoreContext context, ClickHouseDatabase clickDB, UserManager <User> userManager, IHostEnvironment env, NotificationsHub notificationsHub)
 {
     _context          = context;
     _userManager      = userManager;
     _env              = env;
     _fileHandler      = new FileHandler(_env.ContentRootPath, _context);
     _notificationsHub = notificationsHub;
     _logsHandler      = new LogsHandler(clickDB);
 }
Пример #5
0
        public ControllerClickhouse()
        {
            string dbfile = $"{Environment.CurrentDirectory}\\ruitengdb.db";

            mydb = new ClickHouseDatabase(
                new ClickHouseConnectionSettings(str_connectionn),
                new ClickHouseCommandFormatter(),
                new ClickHouseConnectionFactory(),
                null,
                new DefaultPropertyBinder());
            mydb.Open();
        }
Пример #6
0
        public static void CustomBinderDemo()
        {
            var db = new ClickHouseDatabase(
                new ClickHouseConnectionSettings("Compress=True;CheckCompressedHash=False;Compressor=lz4;Host=localhost;Port=9000;User=default;Password=;SocketTimeout=600000;Database=system;"),
                new ClickHouseCommandFormatter(),
                new ClickHouseConnectionFactory(),
                null,
                new NotImplementedPropertyBinder());

            db.Open();

            // Execute query and get result
            var queryMappingSuccess = CastRawValuesToClassTypeProperties(db);

            db.Close();
        }
Пример #7
0
        static void Main(string[] args)
        {
            var db = new ClickHouseDatabase(
                new ClickHouseConnectionSettings("Compress=True;CheckCompressedHash=False;Compressor=lz4;Host=localhost;Port=9000;User=default;Password=;SocketTimeout=600000;Database=default;"),
                new ClickHouseCommandFormatter(),
                new ClickHouseConnectionFactory(),
                null);

            db.Open();
            for (int i = 0; i < 10; i++)
            {
                var res = db.DatabaseExists("test");
                Console.WriteLine($"Database test exists: {res}");
            }

            db.Close();
        }
Пример #8
0
 public LogsHandler(ClickHouseDatabase clickDB)
 {
     _clickDB = clickDB;
 }