{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0624bc95",
   "metadata": {},
   "source": [
    "# sqlcreatedb\n",
    "Create a runcatalog table in a MySQL test database.\n",
    "\n",
    "Based on the code sqlcreatedb.C by Sergey Linev\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "**Author:** Juan Fernando Jaramillo Botero  \n",
    "<i><small>This notebook tutorial was automatically generated with <a href= \"https://github.com/root-project/root/blob/master/documentation/doxygen/converttonotebook.py\">ROOTBOOK-izer</a> from the macro found in the ROOT repository  on Tuesday, May 19, 2026 at 08:15 PM.</small></i>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f03f32e1",
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from ROOT import TSQLServer"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "946c1d7c",
   "metadata": {},
   "source": [
    "read in runcatalog table definition"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4fb894da",
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "fp = open(\"runcatalog.sql\", \"r\")\n",
    "sql = fp.read()\n",
    "fp.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4f7dbd40",
   "metadata": {},
   "source": [
    "open connection to MySQL server on localhost"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8c23e2f1",
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "db = TSQLServer.Connect(\"mysql://localhost/test\", \"nobody\", \"\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19989e21",
   "metadata": {},
   "source": [
    "create new table (delete old one first if exists)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ce433660",
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "res = db.Query(\"DROP TABLE runcatalog\")\n",
    "\n",
    "res = db.Query(sql)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
