// CreateTable create a csv table in this source.
969125
func (m *Source) CreateTable(tableName, csvRaw string) {
	if _, exists := m.raw[tableName]; !exists {
		m.tablenamelist = append(m.tablenamelist, tableName)
	}
	m.raw[tableName] = csvRaw
	m.loadTable(tableName)
}
525047
func (db *baseDB) CreateTable(model interface{}, opt *orm.CreateTableOptions) error {
	return orm.CreateTable(db.db, model, opt)
}
296557
func (s *CrawlerMetrics) SetTablesCreated(v int64) *CrawlerMetrics {
	s.TablesCreated = &v
	return s
}
56680
func NewCSV(writer io.Writer, fileName string, hasHeader bool) (*Table, error) {
	file, err := os.Open(fileName)
	if err != nil {
		return &Table{}, err
	}
	defer file.Close()
	csvReader := csv.NewReader(file)
	t, err := NewCSVReader(writer, csvReader, hasHeader)
	return t, err
}
1002692
func (engine *Engine) Table(tableNameOrBean interface{}) *Session {
	session := engine.NewSession()
	session.isAutoClose = true
	return session.Table(tableNameOrBean)
}
1237087
func LoadTable(schemaName, name, csvRaw string) {
	CsvGlobal.CreateTable(name, csvRaw)
	schema.DefaultRegistry().SchemaRefresh(SchemaName)
}
249529
func CreateTables(db *sql.DB) error {
	// Create all of the data tables.
	for tableName, createCommand := range createTableStatements {
		err := createTable(db, tableName, createCommand)
		if err != nil {
			return err
		}
	}

	return ClearTestingTable(db)
}
1222935
func (m *Source) DropTable(t string) error {
	delete(m.raw, t)
	delete(m.tables, t)
	names := make([]string, 0, len(m.tables))
	for tableName, _ := range m.raw {
		names = append(names, tableName)
	}
	m.tablenamelist = names
	return nil
}
771623
func (m *DbMap) CreateTablesSql() (map[string]string, error) {
	return m.createTables(false, false)
}
247205
func createTable(db *sql.DB, tableName, stmt string) error {
	exists, err := TableExists(db, tableName)
	if err != nil {
		return err
	}

	if !exists {
		log.Infof(`Creating the "%s" table.`, tableName)
		_, err = db.Exec(stmt)
		if err != nil {
			return err
		}
	} else {
		log.Tracef(`Table "%s" exists.`, tableName)
	}

	return err
}
1026705
func MakeTable(headers []string) Table {
	t := MakeHeadlessTable(len(headers))
	for i := range t.columns {
		t.columns[i].title = headers[i]
		t.columns[i].width = len(headers[i])
	}
	return t
}
990569
func CreateTablesLegacy(db *sql.DB) error {
	var err error
	for tableName, createCommand := range createLegacyTableStatements {
		var exists bool
		exists, err = TableExists(db, tableName)
		if err != nil {
			return err
		}

		tableVersion, ok := requiredVersions[tableName]
		if !ok {
			return fmt.Errorf("no version assigned to table %s", tableName)
		}

		if !exists {
			log.Infof("Creating the \"%s\" table.", tableName)
			_, err = db.Exec(createCommand)
			if err != nil {
				return err
			}
			_, err = db.Exec(fmt.Sprintf(`COMMENT ON TABLE %s IS 'v%s';`,
				tableName, tableVersion))
			if err != nil {
				return err
			}
		} else {
			log.Tracef("Table \"%s\" exist.", tableName)
		}
	}

	return ClearTestingTable(db)
}
550747
func CreateTable() *Table {
	t := &Table{elements: []Element{}, Style: DefaultStyle}
	if outputsEnabled.UTF8 {
		t.Style.setUtfBoxStyle()
	}
	if outputsEnabled.titleStyle != titleStyle(0) {
		t.Style.htmlRules.title = outputsEnabled.titleStyle
	}
	t.outputMode = defaultOutputMode
	return t
}
453920
func (session *Session) createAll() error {
	if session.IsAutoClose {
		defer session.Close()
	}

	for _, table := range session.Engine.Tables {
		session.Statement.RefTable = table
		session.Statement.tableName = table.Name
		err := session.createOneTable()
		session.resetStatement()
		if err != nil {
			return err
		}
	}
	return nil
}
286990
func (m *postgresMigrator) createTableIfNotExists() error {
	_, err := m.db.Exec(m.createTable())
	return err
}
1090509
func CreateTable(c *gocql.ClusterConfig, t CTable) error {
	qs := fmt.Sprintf("CREATE TABLE IF NOT EXISTS %v ( %v ) %v ;", t.Name, strings.Join(t.Columns, ", "), t.Options)
	s, err := c.CreateSession()
	if err != nil {
		return err
	}
	defer s.Close()
	log.Printf("Creating table %v\n", t.Name)
	return s.Query(qs).Exec()
}
750450
func New(encoding string) (table *DbfTable) {

	// Create and populate DbaseTable struct
	dt := new(DbfTable)

	dt.fileEncoding = encoding
	dt.encoder = mahonia.NewEncoder(encoding)
	dt.decoder = mahonia.NewDecoder(encoding)

	// set whether or not this table has been created from scratch
	dt.createdFromScratch = true

	// read dbase table header information
	dt.fileSignature = 0x03
	dt.updateYear = byte(time.Now().Year() - 1900)
	dt.updateMonth = byte(time.Now().Month())
	dt.updateDay = byte(time.Now().Day())
	dt.numberOfRecords = 0
	dt.numberOfBytesInHeader = 32
	dt.lengthOfEachRecord = 0

	// create fieldMap to translate field name to index
	dt.fieldMap = make(map[string]int)

	// Number of fields in dbase table
	dt.numberOfFields = int((dt.numberOfBytesInHeader - 1 - 32) / 32)

	s := make([]byte, dt.numberOfBytesInHeader)

	//fmt.Printf("number of fields:\n%#v\n", numberOfFields)
	//fmt.Printf("DbfReader:\n%#v\n", int(dt.Fields[2].fixedFieldLength))

	//fmt.Printf("num records in table:%v\n", (dt.numberOfRecords))
	//fmt.Printf("fixedFieldLength of each record:%v\n", (dt.lengthOfEachRecord))

	// Since we are reading dbase file from the disk at least at this
	// phase changing schema of dbase file is not allowed.
	dt.dataEntryStarted = false

	// set DbfTable dataStore slice that will store the complete file in memory
	dt.dataStore = s

	dt.dataStore[0] = dt.fileSignature
	dt.dataStore[1] = dt.updateYear
	dt.dataStore[2] = dt.updateMonth
	dt.dataStore[3] = dt.updateDay

	// no MDX file (index upon demand)
	dt.dataStore[28] = 0x00

	// set dbase language driver
	// Huston we have problem!
	// There is no easy way to deal with encoding issues. At least at the moment
	// I will try to find archaic encoding code defined by dbase standard (if there is any)
	// for given encoding. If none match I will go with default ANSI.
	//
	// Despite this flag in set in dbase file, I will continue to use provide encoding for
	// the everything except this file encoding flag.
	//
	// Why? To make sure at least if you know the real encoding you can process text accordingly.

	if code, ok := encodingTable[lookup[encoding]]; ok {
		dt.dataStore[29] = code
	} else {
		dt.dataStore[29] = 0x57 // ANSI
	}

	return dt
}