<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/18951" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2012-04-28T18:21:11-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/18951</id>

		<entry>
		<author><name><![CDATA[wac]]></name></author>
		<updated>2012-04-28T18:19:34-04:00</updated>

		<published>2012-04-28T18:19:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99287#p99287</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99287#p99287"/>
		<title type="html"><![CDATA[[SOLVED] MySQL error with INDEX_LENGTH and Auto_increment]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99287#p99287"><![CDATA[
Yes I found that auto_increment does not display the actual total records just the number that have been added and not that are necessarily still there.<br><div class="codebox"><p>Code: </p><pre><code>select count(*) from db.table</code></pre></div>Will display the actual records still in the database.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8485">wac</a> — Sat Apr 28, 2012 6:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2012-04-28T17:57:42-04:00</updated>

		<published>2012-04-28T17:57:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99286#p99286</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99286#p99286"/>
		<title type="html"><![CDATA[[SOLVED] MySQL error with INDEX_LENGTH and Auto_increment]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99286#p99286"><![CDATA[
Looking deeper, I notice that you actually query the information_schema-tables. The "TABLES"-table would contain one row for each table in the database, where the AUTO_INCREMENT column would hold the value for the current auto_increment counter for that table.<br><br>Thus, using SUM() here makes no sense, since you'd only return one row in the first place. Secondly, the auto_increment counter is not guarantee'd to be a sequential enumeration, there may be gaps for various reasons. Further, the AUTO_INCREMENT counter actually holds the next value to be used, not the last one, so unless you explicitly initiated the counter to 0 (default is 1), you'd get the wrong number anyway.<br><br>If you do intend to use the information_schema tables, I'd recommend you look at the TABLE_ROWS column instead:<div class="codebox"><p>Code: </p><pre><code>...set test [::mysql::sel $mysql(handle) "SELECT `TABLE_ROWS` FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA`='mydatabase' AND `TABLE_NAME`='mytable'"if {$test &gt;= 1} {  putserv "privmsg $chan :[::mysql::fetch $mysql(handle)]"}...</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Apr 28, 2012 5:57 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[wac]]></name></author>
		<updated>2012-04-28T17:39:19-04:00</updated>

		<published>2012-04-28T17:39:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99285#p99285</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99285#p99285"/>
		<title type="html"><![CDATA[[SOLVED] MySQL error with INDEX_LENGTH and Auto_increment]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99285#p99285"><![CDATA[
<blockquote class="uncited"><div>That's because you did not use the --list or --flatlist option, and your queries returned 1 rows each in their result. In essence, you'll either have to use the --list or --flatlist options for in-line results, or use ::mysql::fetch to fetch the results (one row at a time) after your call to ::mysql::sel.<br><br>As for your second query, that will not generate the number of rows in the table, unless you have a table column named "Auto_increment" that has the value 1 for each row... More likely, you're thinking of using the COUNT() aggregator instead</div></blockquote><div class="codebox"><p>Code: </p><pre><code>        set test [mysql::fetch $mysql(handle)]</code></pre></div>Worked for both queries, there is a column named id that runs auto_increment. Thanks for your help.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8485">wac</a> — Sat Apr 28, 2012 5:39 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2012-04-28T12:52:14-04:00</updated>

		<published>2012-04-28T12:52:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99284#p99284</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99284#p99284"/>
		<title type="html"><![CDATA[[SOLVED] MySQL error with INDEX_LENGTH and Auto_increment]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99284#p99284"><![CDATA[
That's because you did not use the --list or --flatlist option, and your queries returned 1 rows each in their result. In essence, you'll either have to use the --list or --flatlist options for in-line results, or use ::mysql::fetch to fetch the results (one row at a time) after your call to ::mysql::sel.<br><br>As for your second query, that will not generate the number of rows in the table, unless you have a table column named "Auto_increment" that has the value 1 for each row... More likely, you're thinking of using the COUNT() aggregator instead<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Apr 28, 2012 12:52 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[wac]]></name></author>
		<updated>2012-04-28T18:21:11-04:00</updated>

		<published>2012-04-28T00:03:33-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99276#p99276</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99276#p99276"/>
		<title type="html"><![CDATA[[SOLVED] MySQL error with INDEX_LENGTH and Auto_increment]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99276#p99276"><![CDATA[
What I'm trying to get the code to do is return the table size in the database but all it does is return "1" when the command is run, I'm not quite sure what I'm missing here.<br>Also trying to get how many records are in the database but it also only returns "1".<br><div class="codebox"><p>Code: </p><pre><code>bind pub - !size sizeproc size {nick uhost handle chan arg} {        global mysql libMySQLTcl        set mysql(handle) [mysqlconnect -host $mysql(host) -user $mysql(user) -password $mysql(pass) -port $mysql(port) -db $mysql(db)]        mysqluse $mysql(handle) $mysql(db)        set test [mysqlsel $mysql(handle) "SELECT    SUM((DATA_LENGTH + INDEX_LENGTH - DATA_FREE) / 1024 / 1024)    FROM  INFORMATION_SCHEMA.tables    WHERETABLE_SCHEMA = 'mydatabase'    AND   TABLE_NAME   = 'mytable';"]        putserv "privmsg $chan : $test " mysqlclose $mysql(handle)</code></pre></div><div class="codebox"><p>Code: </p><pre><code>bind pub - !records recordsproc records {nick uhost handle chan arg} {        global mysql libMySQLTcl        set mysql(handle) [mysqlconnect -host $mysql(host) -user $mysql(user) -password $mysql(pass) -port $mysql(port) -db $mysql(db)]        mysqluse $mysql(handle) $mysql(db)        set test [mysqlsel $mysql(handle) "SELECT    SUM(Auto_increment) FROM  INFORMATION_SCHEMA.tables    WHERE TABLE_SCHEMA = 'mydatabase'    AND   TABLE_NAME   ='mytable';"]        putserv "privmsg $chan :$test" mysqlclose $mysql(handle)}</code></pre></div>EDIT: Adding this line about putserv makes the query work thanks to nml375 for the help.<div class="codebox"><p>Code: </p><pre><code>        set test [mysql::fetch $mysql(handle)]</code></pre></div><br><div class="codebox"><p>Code: </p><pre><code>bind pub - !size sizeproc size {nick uhost handle chan arg} {        global mysql libMySQLTcl        set mysql(handle) [mysqlconnect -host $mysql(host) -user $mysql(user) -password $mysql(pass) -port $mysql(port) -db $mysql(db)]        mysqluse $mysql(handle) $mysql(db)        set test [mysqlsel $mysql(handle) "SELECT    SUM((DATA_LENGTH + INDEX_LENGTH - DATA_FREE) / 1024 / 1024)    FROM  INFORMATION_SCHEMA.tables    WHERETABLE_SCHEMA = 'mydatabase'    AND   TABLE_NAME   = 'mytable';"]        set test [mysql::fetch $mysql(handle)]        putserv "privmsg $chan : $test " mysqlclose $mysql(handle)</code></pre></div><div class="codebox"><p>Code: </p><pre><code>bind pub - !records recordsproc records {nick uhost handle chan arg} {        global mysql libMySQLTcl        set mysql(handle) [mysqlconnect -host $mysql(host) -user $mysql(user) -password $mysql(pass) -port $mysql(port) -db $mysql(db)]        mysqluse $mysql(handle) $mysql(db)        set test [mysqlsel $mysql(handle) "select count(*) from db.table;"]        set test [mysql::fetch $mysql(handle)]        putserv "privmsg $chan :$test" mysqlclose $mysql(handle)}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8485">wac</a> — Sat Apr 28, 2012 12:03 am</p><hr />
]]></content>
	</entry>
	</feed>
