Re: [sqlite] How to save live data into sqlite database using c language?

2013-04-28 Thread fnoyanisi
He means, in your HOST struct, instead of defining a lot of in variables for 
each protocol type, just define your ENUM type to hold all possible protocol 
types, so you will insert only one protocol value into your sqlite db.

When you fetch data, it will be just a matter of simple switch/case statement 
to evaluate the protocol value of each record.

On 29/04/2013, at 2:25 PM, Newbie89 <sh_ta...@hotmail.com> wrote:

> Teg-3 wrote
>> Hello Newbie89,
>> 
>> Sunday, April 28, 2013, 3:32:07 AM, you wrote:
>> 
>> N> Thanks for the correction
>> N> ok...I will check first.
>> 
>> 
>> 
>> N> --
>> N> View this message in context:
>> N>
>> http://sqlite.1065341.n5.nabble.com/How-to-save-live-data-into-sqlite-database-using-c-language-tp68519p68521.html
>> N> Sent from the SQLite mailing list archive at Nabble.com.
>> N> ___
>> N> sqlite-users mailing list
>> N>
> 
>> sqlite-users@
> 
>> N> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>> 
>> 
>> I suspect you want one protocol field
>> 
>> enum _protocols
>> {
>> C_PROTOCOL_TCP,
>> C_PROTOCOL_UDP,
>> ..
>> };
>> 
>> 
>> CREATE TABLE host
>> (
>> Src_MAC char(18),
>> Src_IP char(16),
>> Cap_Bytes integer,
>> Protocol integer,
>> 
>> );
>> 
>> With  a single protocol tag per insert. Then you tag each packet insert
>> with the protocol field.
>> 
>> -- 
>> Best regards,
>> Tegmailto:
> 
>> Teg@
> 
>> 
>> ___________
>> sqlite-users mailing list
> 
>> sqlite-users@
> 
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> What do you mean that I want one protocol field?Sorry that I not very
> understand...can you give some example?thanks
> 
> 
> 
> --
> View this message in context: 
> http://sqlite.1065341.n5.nabble.com/How-to-save-live-data-into-sqlite-database-using-c-language-tp68519p68544.html
> Sent from the SQLite mailing list archive at Nabble.com.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How to save live data into sqlite database using c language?

2013-04-28 Thread Newbie89
Teg-3 wrote
> Hello Newbie89,
> 
> Sunday, April 28, 2013, 3:32:07 AM, you wrote:
> 
> N> Thanks for the correction
> N> ok...I will check first.
> 
> 
> 
> N> --
> N> View this message in context:
> N>
> http://sqlite.1065341.n5.nabble.com/How-to-save-live-data-into-sqlite-database-using-c-language-tp68519p68521.html
> N> Sent from the SQLite mailing list archive at Nabble.com.
> N> ___
> N> sqlite-users mailing list
> N> 

> sqlite-users@

> N> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> 
> I suspect you want one protocol field
> 
> enum _protocols
> {
> C_PROTOCOL_TCP,
> C_PROTOCOL_UDP,
> ..
> };
> 
> 
> CREATE TABLE host
> (
> Src_MAC char(18),
> Src_IP char(16),
> Cap_Bytes integer,
> Protocol integer,
> 
> );
> 
> With  a single protocol tag per insert. Then you tag each packet insert
> with the protocol field.
> 
> -- 
> Best regards,
>  Tegmailto:

> Teg@

> 
> ___
> sqlite-users mailing list

> sqlite-users@

> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

What do you mean that I want one protocol field?Sorry that I not very
understand...can you give some example?thanks



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/How-to-save-live-data-into-sqlite-database-using-c-language-tp68519p68544.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How to save live data into sqlite database using c language?

2013-04-28 Thread Newbie89
Let say my C file contain this 2 variable,

struct Packet
{
   char Src_MAC[18], Dest_MAC[18];
   char Net_P[5],Trans_P[5]; 
   char Src_IP[16], Dest_IP[16]; 
   long int Src_Port,Dest_Port, Cap_Bytes;//[ long int Range:
−2,147,483,648 to 2,147,483,647]
};

/* Each Host Information Definition  Host Info Size = 18+16+4+14x2+= 66
Bytes */

struct HOST
{
   char Src_MAC[18];
   char Src_IP[16];
   long int Cap_Bytes;
   int TCP,UDP,ICMP,IP,ARP,OTH_Net, OTH_Trans;   // Protocols
   int ftp,ssh,telnet,domain,www,netbios,other;  // Services   
};

Is it this enough for me to create a table?
If the previous is use C file to save data into log file,then should only
the insert query can use only?




--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/How-to-save-live-data-into-sqlite-database-using-c-language-tp68519p68543.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How to save live data into sqlite database using c language?

2013-04-28 Thread Teg
Hello Newbie89,

Sunday, April 28, 2013, 3:32:07 AM, you wrote:

N> Thanks for the correction
N> ok...I will check first.



N> --
N> View this message in context:
N> 
http://sqlite.1065341.n5.nabble.com/How-to-save-live-data-into-sqlite-database-using-c-language-tp68519p68521.html
N> Sent from the SQLite mailing list archive at Nabble.com.
N> ___
N> sqlite-users mailing list
N> sqlite-users@sqlite.org
N> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


I suspect you want one protocol field

enum _protocols
{
C_PROTOCOL_TCP,
C_PROTOCOL_UDP,
..
};


CREATE TABLE host
(
Src_MAC char(18),
Src_IP char(16),
Cap_Bytes integer,
Protocol integer,

);

With  a single protocol tag per insert. Then you tag each packet insert
with the protocol field.

-- 
Best regards,
 Tegmailto:t...@djii.com

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How to save live data into sqlite database using c language?

2013-04-28 Thread Newbie89
Thanks for the correction
ok...I will check first.



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/How-to-save-live-data-into-sqlite-database-using-c-language-tp68519p68521.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How to save live data into sqlite database using c language?

2013-04-28 Thread Igor Korot
Hi,

On Sun, Apr 28, 2013 at 12:14 AM, Newbie89 <sh_ta...@hotmail.com> wrote:

> previously It used log file to save data. I need  to identify the variables
> which need to logged and save into database. So I need to create the table
> from this file.c
> struct HOST
> {
>char Src_MAC[18];
>char Src_IP[16];
>long int Cap_Bytes;
>int TCP,UDP,ICMP,IP,ARP,OTH_Net, OTH_Trans;   // Protocols
>int ftp,ssh,telnet,domain,www,netbios,other;  // Services
> };
>
> into this
> create table HOST (Src_MAC[18] char,Src_IP[16] char,Cap_Bytes long int,TCP
> int,UDP int,ICMP int,IP int,ARP int,OTH_Net int,OTH_Trans int,ftp int,ssh
> int,telnet int,domain int,www int,netbios int,other int);
>

Nope.
The proper syntax is:

CREATE TABLE host( Src_MAC char(18), Src_IP char(16), Cap_Bytes integer,
TCP integer, UDP integer, ICMP integer);

But it's much more than that.
You should really check what you program does, which queries you will
issue, what other tables you will need, the relationships between different
tables and how you construct you queries for better performance.

Thank you.


>
> right?
> How to I link so that the live data is save into the database?
> I'm  not very well in the connection?
> can give me some guides?
>
>
>
>
> --
> View this message in context:
> http://sqlite.1065341.n5.nabble.com/How-to-save-live-data-into-sqlite-database-using-c-language-tp68519.html
> Sent from the SQLite mailing list archive at Nabble.com.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] How to save live data into sqlite database using c language?

2013-04-28 Thread Newbie89
previously It used log file to save data. I need  to identify the variables
which need to logged and save into database. So I need to create the table
from this file.c
struct HOST
{
   char Src_MAC[18];
   char Src_IP[16];
   long int Cap_Bytes;
   int TCP,UDP,ICMP,IP,ARP,OTH_Net, OTH_Trans;   // Protocols
   int ftp,ssh,telnet,domain,www,netbios,other;  // Services   
};

into this
create table HOST (Src_MAC[18] char,Src_IP[16] char,Cap_Bytes long int,TCP
int,UDP int,ICMP int,IP int,ARP int,OTH_Net int,OTH_Trans int,ftp int,ssh
int,telnet int,domain int,www int,netbios int,other int);

right?
How to I link so that the live data is save into the database?
I'm  not very well in the connection?
can give me some guides?




--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/How-to-save-live-data-into-sqlite-database-using-c-language-tp68519.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users